Solved

Adding HTML Help to VB6 app

Posted on 2008-10-30
4
772 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now