Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link 'Chm' file to Vb app

Status
Not open for further replies.

fathimasulthan

Programmer
Feb 19, 2001
17
SG
How to link the help file (".chm") to my Visual basic application.

In winhelp('.hlp') , I have done this by the following Steps
* creating a footnote In the 'rtf' file as a topic id
* Maping that topic with a Numeric valeu.
* Assigned those Numeric values to the corresponding forms 'helpcontextid'.


But I am unable proceed the same things using HTML Help.

Kindly let me Know the solution

Thanx in advance
Fathima
 
This is a start. For context sensitive help at control level, you are on your own.
[/code]
Private Form_Load
HTMLHelp.WindowHandle = Me.hWnd
HTMLHelp.Filename = wParms.objFS.BuildPath(App.Path, "VBCompare.chm")
End Sub
Private Sub MnuHelpTopics_Click()
HTMLHelp.DisplayTopic "CompareForm.HTM"
End Sub

'Public Module
Option Explicit

Const HH_DISPLAY_TOPIC = &H0
Const HH_SET_WIN_TYPE = &H4
Const HH_GET_WIN_TYPE = &H5
Const HH_GET_WIN_HANDLE = &H6
Const HH_DISPLAY_TEXT_POPUP = &HE ' Display string resource ID or
' text in a pop-up window.
Const HH_HELP_CONTEXT = &HF ' Display mapped numeric value in
' dwData.
Const HH_TP_HELP_CONTEXTMENU = &H10 ' Text pop-up help, similar to
' WinHelp's HELP_CONTEXTMENU.
Const HH_TP_HELP_WM_HELP = &H11 ' text pop-up help, similar to
' WinHelp's HELP_WM_HELP.
Public WindowHandle As Long
Public Filename As String



Declare Function HTMLHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, ByVal pszFile As String, _
ByVal uCommand As Long, ByVal dwData As Long) As Long
Public Sub DisplayContents()
' HTML Help file launched in response to a button click:
'hWnd is a Long defined elsewhere to be the window handle
'that will be the parent to the help window.
Dim hwndHelp As Long
Dim strResponse As String
'The return value is the window handle of the created help window.
On Error Resume Next
hwndHelp = HTMLHelp(WindowHandle, Filename, HH_DISPLAY_TOPIC, 0)
If Err.Number <> 0 Then strResponse = Err.Description
On Error GoTo 0
If hwndHelp = 0 Or Len(strResponse) > 0 Then
NoHelp strResponse
End If
End Sub
Public Sub DisplayTopic(strTopic As String)
' HTML Help file launched in response to a button click:
'hWnd is a Long defined elsewhere to be the window handle
'that will be the parent to the help window.
Dim hwndHelp As Long
Dim strResponse As String
'The return value is the window handle of the created help window.
On Error Resume Next
hwndHelp = HTMLHelp(WindowHandle, Filename & &quot;::/&quot; & strTopic, HH_DISPLAY_TOPIC, 0)
If Err.Number <> 0 Then strResponse = Err.Description
On Error GoTo 0
If hwndHelp = 0 Or Len(strResponse) > 0 Then
NoHelp strResponse
End If
End Sub

' A specific topic identified by the variable ContextID is launched
' in response to this button click:
Public Sub DisplayContext(lngContextId As Long)
Dim hwndHelp As Long
Dim strResponse As String
'The return value is the window handle of the created help window.
On Error Resume Next
hwndHelp = HTMLHelp(WindowHandle, Filename, HH_HELP_CONTEXT, lngContextId)
If Err.Number <> 0 Then strResponse = Err.Description
On Error GoTo 0
If hwndHelp = 0 Or Len(strResponse) > 0 Then
NoHelp strResponse
End If
End Sub
Private Sub NoHelp(strErr As String)
Dim strResponse As String
Dim objW As Object
If Len(strErr) = 0 Then
On Error Resume Next
Set objW = wParms.objFS.GetFile(Filename)
If Err.Number <> 0 Then strResponse = Err.Description
If Len(strResponse) > 0 Then
strResponse = strResponse & vbCrlf & &quot;Help File=&quot; & Filename
End If
On Error GoTo 0
Else
strResponse = strErr
End If
If Len(strResponse) = 0 Then
strResponse = strErr & vbCrlf
strResponse = strResponse & &quot;Help File=&quot; & Filename & vbCrlf
strResponse = strResponse & &quot;Unable to start HTML Help.&quot; & vbCrlf
strResponse = strResponse & &quot;You must have at least IE 4.01 and the HTML Help Viewer installed.&quot; & vbCrlf
strResponse = strResponse & &quot;Download HHUPD.EXE from Microsoft to intall the HTML Help Viewer.&quot;
End If
If Len(strResponse) > 0 Then
MsgBox strResponse, vbQuestion + vbOKOnly, &quot;HTML Help File&quot;
End If
End Sub
[/code]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top