HOWTO: Use HTML Help Text Popup Windows in a VBasic ProgramID: Q192118
|
This article describes how to use HTML Help context-sensitive text popup
windows in a Visual Basic application. If the user places the cursor on a
control and presses the F1 key, the context-sensitive text appears in a
small box.
NOTE: This article assumes that the reader has already prepared an HTML
Help project file with the HTML Help Workshop and is ready to add context-
sensitive text popup windows to it.
.topic 1
This is a text popup window for topic 1.
.topic 2
This is a text popup window for topic 2.
.topic 3
This is a text popup window for topic 3.
For each topic, the ".topic" is required, followed by a space and
a numeric constant or number. The line immediately following must
contain the text that you want to appear in the popup window.
.topic IDH_MYTOPIC1
This is a text popup window for topic 1.
.topic IDH_MYTOPIC2
This is a text popup window for topic 2.
.topic IDH_MYTOPIC3
This is a text popup window for topic 3.
In this example, you need to define the constants IDH_MYTOPIC1,
IDH_MYTOPIC2, IDH_MYTOPIC3 in the [MAP] section of the help project file
as follows:
[MAP]
#define IDH_MYTOPIC1 1
#define IDH_MYTOPIC2 2
#define IDH_MYTOPIC3 3
There is additional information about creating the text topic file in
the HTML Help Workshop Help under the topic "To create a
context-sensitive help topic file".
[FILES]
topic1.htm
topic.htm
cpopups.txt
[TEXT POPUPS]
#include cpopups.txt
NOTE: Use a text editor to add the [TEXT POPUPS] and the #include
statement.
Public Const HH_TP_HELP_WM_HELP = &H11
Declare Function HtmlHelpByRefArg Lib "hhctrl.ocx" Alias "HtmlHelpA"
(ByVal hwndCaller As Long, ByVal pszFile As String, ByVal uCommand As
Long, ByRef dwData As Any) As Long
Type HH_IDPAIR
dwControlId As Long
dwTopicId As Long
End Type
'This array should contain the number of controls that have
'context-sensitive help, plus one more for a zero-terminating
'pair.
Public ids(4) As HH_IDPAIR
Declare Function GetDlgCtrlID Lib "user32" (ByVal hWnd As Long) As
Long
Public Const g_sHTMLHelpFile As String =
myhelpfile.chm::/cpopups.txt"
NOTE: This example assumes the .chm file is in the same directory as
the Visual Basic application because no path is specified.
Private Sub Form_Load()
ids(0).dwControlId = GetDlgCtrlID(Me.MyButton.hWnd)
ids(0).dwTopicId = 1
ids(1).dwControlId = GetDlgCtrlID(Me.MyText.hWnd)
ids(1).dwTopicId = 2
ids(2).dwControlId = GetDlgCtrlID(Me.MyList.hWnd)
ids(2).dwTopicId = 3
ids(3).dwControlId = 0
ids(3).dwTopicId = 0
End Sub
NOTE: The last pair in the array must contain zeros (0).
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then
iRetCode = HtmlHelpByRefArg(Me.ActiveControl.hWnd,_
g_sHTMLHelpFile, HH_TP_HELP_WM_HELP, ids(0))
End If
End Sub
"Official Microsoft HTML Help Authoring Kit", Steve Wexler, Microsoft
Press, 1998
The HTML Help Web site:
http://www.microsoft.com/workshop/author/htmlhelp/default.asp
Keywords : kbAPI kbHTMLHelp kbVBp500
Version :
Platform :
Issue type : kbhowto
Last Reviewed: May 13, 1999