Solved

Adding HTML Help to VB6 app

Posted on 2008-10-30
4
800 Views
Last Modified: 2012-05-05
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
Comment
Question by:SETP
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 250 total points
ID: 22839353
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
 

Author Comment

by:SETP
ID: 22841290
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
 
LVL 7

Assisted Solution

by:help-info
help-info earned 250 total points
ID: 22842380
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
 

Author Closing Comment

by:SETP
ID: 31511572
Thanks, that did it
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA to copy paste columns form one file to other 20 90
Put text in a picture ASP.NET C# 2 60
Set email body to html using vbscript 6 49
RUNRMTCMD from AS/400 12 68
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question