
WinHelp 32 Bit API Routines
Disclaimer: HTML has limited formatting capabilities. For that reason, routines on this page do not conform to normally accepted indention protocols. Elsewise, these routines work; I make no claim they are "good form."
'Declare the Winhelp function and associated consts in the form's declarations section, or in a separate module file (*.bas). The declaration should be one unbroken line or insert line breaks as supported by your version of Visual basic.
Declare Function WinHelp Lib "User32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long
Public Const HELP_FINDER = 11
Public Const HELP_QUIT =
&H2
Public Const HELP_KEY = &H101
Note: Many an experienced programmer
will tell you declaring an API or variable "As Any" is asking for trouble. If
only one function is needed call the dwData variable as a Long (&) or String ($) as
required. If both functions are needed, you may want to declare the API twice, once as a
"Long" (&) and once as a "String" ($). The second declaration
might look like this (note the "dw"):
The declaration should be one unbroken line
or insert line breaks as supported by your version of Visual Basic.
Declare Function dwWinHelp
Lib "User32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile
As String, ByVal wCommand As Long, ByVal dwData As
String) As Long
'The following routine will call the WinHelp tabbed dialog.
Private Sub mnuHelpTopics_Click()
Dim
x&, helpfile$, Drive$, Path$
'direct path to application directory /
folder
Path$
= App.Path
Drive$ = Left$(Path$, 2)
ChDrive Drive$
ChDir
Path$
helpfile$ = "xxxxx.hlp"
x& = WinHelp(x&, helpfile$, HELP_FINDER, 0&)
End Sub
Note: If you are invoking the WinHelp
API several times, you may want to make a separate application path routine.
'Visual Basic has "What's This" help capability, but you must give up a number of options to use it. In lieu of using the core language function, these routines use the WinHelp API and the HELP_KEY const to simulate the "What's This" by use of the right mouse button.
Private Sub buttonHelp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
PopupMenu mnuWhatHelp
End If
End Sub
Create a secondary window(s) in the help
project file using RGB (255, 255, 226) as the background color. Add a unique word or
phrase with the "K" footnote in the *.rtf file topic, then use that same work or
phrase in the following routine.
Private Sub mnuWhatHelpPU_Click()
Dim x&, keyWord$, helpfile$, Drive$, Path$
'direct path to application directory /
folder
Path$
= App.Path
Drive$ = Left$(Path$, 2)
ChDrive Drive$
ChDir
Path$
helpfile$ = "xxxxx.hlp"
keyWord$ = "What Is The Help Button"
'Note: You may want to place the
WinHelp API call in a separate routine - calling that routine in its stead.
x& = WinHelp(x&, helpfile, HELP_KEY, keyWord$)
End Sub
'Note: All "K" footnotes are
displayed in the help file index, so the word or phrase selected should be intelligible.
Be sure to use the (>) footnote in the *rtf file topic. Doing so will insure that topic
is always displayed in the selected secondary window.
'In lieu of matching context -ids with
context strings in the [MAP] section of the project
file, you can use the HELP_KEY const to create context sensitive help (F1). Add a
unique word or phrase with the "K" footnote in the *.rtf file topic, then use
that same work or phrase in the following routine.
Note: All "K" footnotes are
displayed in the help file index, so the word or phrase selected should be intelligible.
Normally there is no reason to use this method in lieu of context-ids; however if you are
using HELP_KEY to simulate "What's This" type help, then this routine is useful.
Private Sub buttonHelp_KeyDown(KeyCode As
Integer, Shift As Integer)
Dim
x&, keyWord$, helpfile$, Drive$, Path$
If
KeyCode = vbKeyF1 Then
'direct path to application directory /
folder
Path$
= App.Path
Drive$ = Left$(Path$, 2)
ChDrive Drive$
ChDir
Path$
helpfile$ = "xxxxx.hlp"
keyWord$ = "What Is The Help Button"
x& = WinHelp(x&, "helpfile", HELP_KEY, keyWord$)
End If
End Sub
WinHelp API call to close the associated help file when the end user exits the application.
Private
Sub Form_Unload(Cancel As Integer)
Dim
Path$,
Drive$, helpfile$, x&
'direct path to application directory /
folder
Path$ = App.Path
Drive$ = Left$(Path$, 2)
ChDrive Drive$
ChDir
Path$
helpfile$ = "xxxxx.hlp"
x& = WinHelp(x&, helpfile$, HELP_QUIT, 0&)
End
End Sub
| The Freelance Story Teller |
| Voice: 405 720 7995 |
| Fax: 405 720 7995 |
| 11808 Silvermoon Drive, Oklahoma City, OK 73162 |