Results 1 to 29 of 29

Thread: Invoking help

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Smile Invoking help

    Normally, in a VB app, you can press F1 and it will bring up the help file that is specified in the project properties (App.HelpFile).

    We have a completed app and we're just wanting to add help but unfortunately our application does not resond to F1 anymore.

    Is there anyway to fix this?

    If not, is there anyway to invoke the help file mannually (I'd rather not use a Shell command if possible)?


  2. #2
    Just add a menu item called Help, and give it the shortcut key F1. Or, if you don't want to use menus in your proggie, there is an article on VB world about hotkeys.

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Unhappy That's not the problem.

    I've got a "help" menu item but what code do I use to actually invoke the help file?

  4. #4
    I believe you can use a common dialog control. I'm a little fuzzy on it (I just make HTML files, not .hlp files), so check the VB help (go to CommonDialog control in the index).

  5. #5

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Thumbs up .chm files

    My application doesn't work with either HLP or CHM (HTML) help files.

    How do you "invoke" your html help files?

  6. #6
    ShellExecute. In fact, Simonm, try doing that. Search for ShellExecute on the forum.

  7. #7
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    try this:

    Code:
    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 Const HH_DISPLAY_TOPIC = &H0
    Public Const HH_HELP_CONTEXT = &HF
    
    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)
            Else
                lngReturn = HtmlHelp(WindowHandle, HelpFile, HH_HELP_CONTEXT, Topic)
            End If
            
            LaunchHTMLHelp = CBool(lngReturn)
        
        End If
    
    End Function
    hope this is what u need
    -= a peet post =-

  8. #8
    But does that work in Windows 95 and NT, which didn't come with .CHM support? Try ShellExecute first!

  9. #9
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    filburt1 it will work on most computers. well not all ... but this sample makes it possible for him to use context sensitive help.

    eg.
    a user is in a partic. part of the program and the user hit F1, he/she will be taken to the correct part of the helpfile...
    -= a peet post =-

  10. #10

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Thumbs up Cheers!

    Thanks for all the help everyone!

  11. #11
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Re: Invoking help

    oh yeah, and :


    Originally posted by simonm
    ... file mannually (I'd rather not use a Shell command if possible)?

    -= a peet post =-

  12. #12
    Maybe he meant the shell command. Oh, well, we solved the problem, like we always do.

  13. #13

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Question Actually...

    Will HtmlHelp work on Windows 98 and Windows 2000 machines?

  14. #14

  15. #15
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by filburt1
    Oh, well, we solved the problem, like we always do.
    yeah "filburt the fixer" and "peet the pimp" did it again

    (damn I need a new nick name )
    -= a peet post =-

  16. #16
    New Member
    Join Date
    Jul 2001
    Posts
    5
    Try this code. This works with .hlp files. I have not tried with .chm files.

    Option Explicit

    Global Const m_Help_Quit = &H2 ' Terminates help

    Declare Function WinHelp Lib "User32.dll" Alias "WinHelpA" (ByVal hwnd As Long, ByVal HelpFile As String, _
    ByVal Cmd As Long, ByVal Data As Any) As Long

    Dim m_hWnd_Main_Window As Long ' tells WINHELP the helpfile owner

    'Routine to Initialize Help
    Public Sub SetAppHelp(ByVal hWnd_Main_Window)

    'Setup helpfile variables
    m_hWnd_Main_Window = hWnd_Main_Window
    If Right$(Trim$(App.Path), 1) = "\" Then
    App.HelpFile = App.Path + "HelpFilename.hlp"
    Else
    App.HelpFile = App.Path + "\HelpFilename.hlp"
    End If

    End Sub

    'Quits Help
    Public Sub QuitHelp()
    Dim Result As Variant
    Result = WinHelp(m_hWnd_Main_Window, App.HelpFile, m_Help_Quit, chr$(0) + chr$(0) + chr$(0) + chr$(0))
    End Sub

    'On your form load event, initialize the help file:
    Private Sub Form_Load()

    'Initialize help
    SetAppHelp Me.hwnd

    end sub

  17. #17
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    peet, that is exactly what I have been looking for to open help files. I have one question though..... where do you set specific
    values in the CHM in order for the right topic to be opened when
    you call help with a parameter?
    Bababooey
    Tatatoothy
    Mamamonkey

  18. #18
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Use this code to open to a specific page in an CHM file.

    VB Code:
    1. Private Const HH_DISPLAY_TOPIC = &H0
    2. Private Declare Function htmlHelpTopic Lib "hhctrl.ocx" _
    3.     Alias "HtmlHelpA" (ByVal hwnd As Long, _
    4.     ByVal lpHelpFile As String, _
    5.     ByVal wCommand As Long, _
    6.     ByVal dwData As String) As Long
    7.  
    8.  
    9. Public Sub ShowHelp(hwndCaller As Long, sFile As String, sHelpPage As String)
    10.     Call htmlHelpTopic(hwndCaller, sFile, HH_DISPLAY_TOPIC, sHelpPage)
    11. End Sub
    12.  
    13. 'To Call
    14. Private Sub mnuHelp()
    15.      Dim sHelpFile As String
    16.      sHelpFile = App.Path & "\myhelp.chm"
    17.      ShowHelp Me.hWnd, sHelpFile, "main.htm"
    18. End Sub

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  19. #19
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    i know how to do that part, what i'm wondering is, in my CHM file which I have made, where do i put topic codes or whatever in order for the function to find the right thing?

    this is on the HTML help side, not the VB side

    Thanks
    Bababooey
    Tatatoothy
    Mamamonkey

  20. #20
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    nm, i think i got it, thx for the help!
    Bababooey
    Tatatoothy
    Mamamonkey

  21. #21
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    In my code maybe you didn't notice that it does not rely on codes to call the topics. You call it by page name (e.g. main.htm in the example). You don't need to add any codes to your CHM help file. In the older WinHelp (HLP) files you included a topic map which assigned each topic a value.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  22. #22
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    yes thanks, i thought it was something else maybe, but using
    your method I can access specific topics using anchors and such.
    Which is something i use heavily in my CHM to find different
    things.

    Thanks for your help!
    Bababooey
    Tatatoothy
    Mamamonkey

  23. #23
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Re: Cheesy easy way

    Originally posted by James Stanich
    Add a web browser control in your project and load your html help filles as needed. Only thing can you load html files in a resourse file for retrieval at runtime?
    hmm... think this will be a difficult task, u will have to store all the graphics and html in u'r resource, then save it as files when u want to load it.
    -= a peet post =-

  24. #24
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by peet
    "peet the pimp"
    Got any...girls...for me yet peet?!


  25. #25
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by chrisjk
    Got any...girls...for me yet peet?!

    sure Chris, you bring the gum, I'll bring the girls
    -= a peet post =-

  26. #26
    Addicted Member
    Join Date
    Mar 2001
    Location
    Greece
    Posts
    164

    CHM files...

    Isn't there any way to load CHM files using the CommonDialog control as done with HLP files ?

    If not, what method is compatible to NT/2000/XP : calling HtmlHelp API or ShellExecute API ?

    Thanks.

  27. #27
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Hyperspaced, u want the users to select the helpfile using the common dialog control ?

  28. #28
    Addicted Member
    Join Date
    Mar 2001
    Location
    Greece
    Posts
    164

    No. just a fixed help file

    No. Just a fixed help file. I tried calling both ShellExecute and HtmlHelp with succesfull results in my Win98SE (clearly calling htmlHelp API is much cooler)
    However, I don't know if this is the case in NT/2000/XP.

    Thanks

  29. #29
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    the code I posted earlier in this thread works fine on NT and win2k, have not tested on xp, but I assume there won't be any problems there either.

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