
250
USING ROBOHELP HTML 9
Context-sensitive Help
Last updated 12/14/2011
Private Declare Function ShellExecute Lib _
"shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
The
ShowHelp
function requires an explicit filename or URL. But for context-sensitive Help, it is better to code the
application to use context IDs rather than explicit topic names. Use the following sample function,
ShowHelpContext
,
which maps integer context IDs to topic name strings, then calls
ShowHelp
to launch the topic.
Public Function ShowHelpContext(nContextId As Integer) As Boolean
Dim strTopic As String
Dim bIsLocal As Boolean
bIsLocal = True
Select Case nContextId
Case HH_GADGET_DIALOG
strTopic = "gadget.htm"
Case HH_WHATSIT_DIALOG
strTopic = "whatsit.htm"
Case HH_WIDGET_DIALOG
strTopic = "widget.htm"
Case HH_TECH_SUPPORT:
strTopic = "http://www.mycompany.com"
bIsLocal = False
Case Else
strTopic = "unknown-context.htm"
End Select
ShowHelpContext = ShowHelp(strTopic, bIsLocal)
End Function
..............................................................................................................................................
Using
ShowHelpContext
makes maintaining context-sensitive Help much easier because, if a topic name changes,
only one function must be modified. Declare context IDs (for example,
HH_GADGET_DIALOG
) as constants that can be
shared among the program modules that use context-sensitive WebHelp or WebHelp Pro.
Const HH_GADGET_DIALOG As Integer = 1
Const HH_WHATSIT_DIALOG As Integer = 2
Const HH_WIDGET_DIALOG As Integer = 3
Const HH_TECH_SUPPORT As Integer = 4
Connect context-sensitive WebHelp and WebHelp Pro topics to Visual C++ applications
Note:
This information is for developers who must connect context-sensitive WebHelp and WebHelp Pro topics to Visual
C++ applications.
The sample code provided here uses a function called
ShowHelp
that opens a local or remote topic regardless of the
browser type.
The
ShowHelp
function has two parameters:
szTopic
takes a URL or local filename as a value, and
bIsLocal
takes a
Boolean value. It indicates whether the first parameter is a local filename (
TRUE
) or remote URL (
FALSE
). If the file is
local,
ShowHelp
tells the browser to find the file in the Help subfolder of the application folder.