• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 915
  • Last Modified:

Adding HTML Help to VB6 app

I'm trying to add HTML help to a VB6 app but I'm having no luck. I have a couple of HTML files, which I've compiled with the Microsoft HTML Help Workshop 4.74.8702.0 together with an alias and a header file. I want my VB6 app to be able to display the relevant HTML help file depending on which window the user is in when he hits the F1 key. In my VB6 app, I have the following line of code in the Form_Load event:

App.HelpFile = App.path & "\TMS.chm"  'TMS.chm is the name of the compiled HTML help file

Then for every window in my app, I assign an ID to the HelpContextID property. In my chm help file, I then have two text files, an alias file which looks like this:

IDH_SavingFiles=Saving Files.htm
IDH_OpeningFiles=OpeningFiles.htm
IDH_CreatingANewFile=Creating A New File.htm
etc...

and a header file which looks like this:

#define IDH_SavingFiles 1000
#define IDH_OpeningFiles 1010
#define IDH_CreatingANewFile 1020
etc...

So in one of my VB app's windows, I'll have the HelpContextID set to 1000, on another windows I'll have it set to 1010, on anoter it'll be 1020, etc. However, when I run the app, it doesn't matter which window I'm in. When I hit the F1 key, I get the following error message:

HH_HELP_CONTEXT called without a [MAP] section

The help file then pops up but displays the last help topic - regardless of what window I was on when I hit F1. Any ideas?
0
SETP
Asked:
SETP
  • 2
2 Solutions
 
Luis PérezSoftware Architect in .NetCommented:
I've attached the cHtmlHelp.cls class for VB6 (renamed as TXT because EE doesn't allow to upload cls files, so change it's extension before use). This class helps you to manage the use of HTML help files in VB6.

I think that the easiest way that you can use this class is as follows:

1.- In a .bas module, declare a global instance of a cHtmlHelp object:
Public GLOBAL_HELP as New cHtmlHelp
Also, don't forget to set up Help file in earlier inizialization of your app code (form load of your first form or sub main)
GLOBAL_HELP.HelpFile = App.Path & "\TMS.chm"

2.-Set up KeyPreview property of all of your forms in which you want to show context help to True.

3.- In each of those forms, intercept KeyDown event:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF1 Then
        GLOBAL_HELP.hWnd = Me.hWnd
        GLOBAL_HELP.DisplayTopic "your_topic_id_here"
    End If
End Sub

Hope that helps.
cHtmlHelp.txt
0
 
SETPAuthor Commented:
Thanks RolandDeschain for your reply. I did exactly as you tols me, but when I hot the F1 key, I see the PC does something (the cursor turns to an hourglass for a second), but the help file doesnt appear. Any ideas?
0
 
help-infoCommented:
One thing I see right away that might be the problem ..
Please avoid SPACE in your filenames and use underscore "_" before compiling a CHM file.

You maybe interested in the following URL's:
http://www.help-info.de/en/Help_Info_HTMLHelp/hh_context-id.htm
http://www.help-info.de/en/Help_Info_HTMLHelp/hh_api.htm#vb6

There is a known problem with MDI applications calling CHM's.

See for VB6 - HTMLHelp (CHM) download example:
http://www.help-info.de/en/Visual_Basic/vb.htm

Best regards
Ulrich Kulle
Microsoft MVP - Help
***********************************
0
 
SETPAuthor Commented:
Thanks, that did it
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now