VB and VBA Users Source Code: Displaying HTML help files
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Displaying HTML help files
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Thursday, March 15, 2001
Hits:
695
Category:
Windows API
Article:
The following code demonstrates a technique for showing HTML help files. Option Explicit Private Declare Function HTMLHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" (ByVal hWnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long Private Declare Function GetActiveWindow Lib "user32" () As Long Private Const HH_DISPLAY_TOC = &H1, HH_DISPLAY_INDEX = &H2, HH_DISPLAY_SEARCH = &H3 'Purpose : Shows a windows help file (chm file) 'Inputs : sHelpFile The path to the help file. ' [lDisplayType] The section of the help file to display. ' Can be any of the HH_DISPLAY_ constants. ' [lContextID] The context ID of the topic to display. 'Outputs : Returns the handle of the Help file window on success, else returns zero. 'Author : Andrew Baker 'Date : 03/09/2000 13:58 'Notes : GetActiveWindow can be replaced by Me.Hwnd in VB 'Revisions : Function HTMLHelpShow(sHelpFile As String, Optional lDisplayType As Long = HH_DISPLAY_TOC, Optional lContextID As Long) As Long HTMLHelpShow = HTMLHelp(GetActiveWindow, sHelpFile, lDisplayType, lContextID) End Function 'Demonstration code Sub Test() 'Show Helpfile Debug.Print HTMLHelpShow("C:\myhelpfile.chm") End Sub 'VB Show specific help context Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then Debug.Print HTMLHelpShow("C:\myhelpfile.chm", , Me.ActiveControl.HelpContextID) End If End Sub 'VBA Show specific help context Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = vbKeyF1 Then Debug.Print HTMLHelpShow("C:\myhelpfile.chm", , Me.ActiveControl.HelpContextID) End If End Sub
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder