Link to home
Start Free TrialLog in
Avatar of apsoft
apsoft

asked on

html help

Hi
I have chm help file compiled from 2 html pages (pageA, pageB).
I have simple app in VB with 2 forms (frmA and frmB).

What can I do to associate pageA with frmA and pageB with frmB, so if user push F1 on form can get appropriate html page ?

I try do this:
1. set path to chm file in app project property.
2. set HelpContextID on each form to unique value (frmA: 1001, frmB: 1002);

What can i do with chm help file to associate this values with proper html page ?

Alex
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Perform the following steps in your Visual Basic application:


Create a new project, Form1 is created by default. Add a few controls to the form.


Add a module to the project, and add the following constants to the declaration section of the module:


      Public Const HH_HELP_CONTEXT = &HF

      Public Const MYHELP_FILE = "myfile.chm"
 
NOTE: "myfile.chm" is the path and name of the HTML Help file (.chm) you created earlier.


Add the following HTML Help API declaration to the module:



      Public Declare Function HtmlHelpLongArg Lib "hhctrl.ocx" _
          Alias "HtmlHelpA" (ByVal hwndCaller As Long, _
          ByVal pszFile As String, ByVal uCommand As Long, _
          ByVal dwData As Long) As Long
 
Intercept the form's KeyUp method to capture the F1 key using the following sample code in the Form KeyUp event procedure:



      Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
         dim iRetCode As Long
         If KeyCode = vbKeyF1 Then
             iRetCode = HtmlHelpLongArg(Me.ActiveControl.hWnd,_
              MYHELP_FILE,HH_HELP_CONTEXT,Me.ActiveControl.HelpContextID)
         End If
      End Sub
 
Set the form's KeyPreview, WhatsThisHelp, and WhatsThisButton properties to TRUE.


Set the HelpContextID property of each control on the form to a value from the help project file's MAP section.


Run the Visual Basic application. Select a control on the form and press the F1 key. The appropriate context-sensitive help topic should appear on the screen.
Avatar of PNJ
PNJ

Isn't it as simple as associating PageA with "1001" and PageB with "1002" in the CHM file itself?

So long as App.HelpFile = "path to CHM file" and each HelpContextID is set to 1001 etc then F1 works without any other code.
Avatar of apsoft

ASKER

I belive it is as simple as associting HelpContextID in form with proper number.
But my question is: how can i associate this number with proper topic in chm file ????

Can you explain with details this job ?
Alex
ASKER CERTIFIED SOLUTION
Avatar of PNJ
PNJ

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apsoft

ASKER

"How to Create Context Sensitive HTML Help Files (Q242433)" is the document i need!
Thanks.