Solved

Adding HTML Help to VB6 app

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

947 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

19 Experts available now in Live!

Get 1:1 Help Now