XL5: Using the WinHelp Function with Visual BasicID: Q121115
|
This article describes how to use the Microsoft Windows version 3.1 WinHelp function with Visual Basic, Applications Edition, to use custom Help files with applications you create. This article assumes that you are familiar both with Visual Basic, Applications Edition, and with creating custom Help files.
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/The following examples include:
'---------------------------------------------------------------------
'GLOBAL DECLARATION SECTION
'---------------------------------------------------------------------
'The following two lines must be entered into a single line in your Visual
'Basic module.
Public Declare Function WinHelp% Lib "USER" (ByVal hwnd As Integer, _
ByVal HelpFile$, ByVal wCommand As Integer, ByVal dwData As Any)
'Predefined Help Constants
Const HELP_CONTEXT = &h1 'Display topic in ulTopic
Const HELP_QUIT = &h2 'Terminate help
Const HELP_INDEX = &h3 'Display index
Const HELP_CONTENTS = &h3 'Display Contents for help
Const HELP_HELPONHELP = &h4 'Display help on using help
Const HELP_SETINDEX = &h5 'Set the current Index for multiindex help
Const HELP_SETCONTENTS = &h5 'Set the Contents for help
Const HELP_CONTEXTPOPUP = &h8 'Display index in popup window
Const HELP_FORCEFILE = &h9 'Ensure that help displays correct file
Const HELP_KEY = &h101 'Display topic for keyword in dwData
Const HELP_COMMAND = &h102 'Execute a Winhelp macro
Const HELP_PARTIALKEY = &h105 'Call the Windows help search engine
Const HELP_FINDER = &hB 'Display the help topics dialog box
'----------------------------------------------------------------------
'SHOWHELPTOPIC PROCEDURE
'Displays Help for a particular topic identified by a context number
'that has been defined in the [MAP] section of the .HPJ file.
'dwData is an unsigned long integer containing the context number
'for the topic.
'----------------------------------------------------------------------
Sub ShowHelpTopic()
Dim ContextID As Long
ContextID = 2697
WinHelp 0, "c:\excel\macrofun.hlp", HELP_CONTEXT, ContextID
End Sub
'----------------------------------------------------------------------
'HELPONHELP PROCEDURE
'Displays the Contents topic of the designated Using Help file.
'dwData is ignored and should be set to zero length
'----------------------------------------------------------------------
Sub HelponHelp()
WinHelp 0, "c:\excel\macrofun.hlp", HELP_HELPONHELP, ""
End Sub
'----------------------------------------------------------------------
'KEYWORDSEARCH PROCEDURE
'Displays the topic found in the keyword list that matches the keyword
'passed in the dwData parameter if there is one exact match. If there
'is more than one match, displays the Search dialog box with the topics
'listed in the Go To list box. If there is no match, displays the search
'dialog box.
'dwData is a string that contains a keyword for the desired topic.
'-----------------------------------------------------------------------
Sub KeywordSearch()
WinHelp 0, "c:\excel\macrofun.hlp", HELP_PARTIALKEY, "WHILE-NEXT loops"
End Sub
'-----------------------------------------------------------------------
'HELPCONTENTS PROCEDURE
'Displays the Help contents topic as defined by the Contents option
'in the [OPTIONS] section of the .HPJ file.
'dwData is ignored and should be set to 0 length.
'-----------------------------------------------------------------------
Sub HelpContents()
WinHelp 0, "c:\excel\macrofun.hlp", HELP_CONTENTS, ""
End Sub
'-----------------------------------------------------------------------
'QUITHELP PROCEDURE
'Informs the Help application that Help is no longer needed.
'If no other applications have asked for Help, Windows closes the Help
'application.
'dwData is ignored and should be set to zero length.
'-----------------------------------------------------------------------
Sub QuitHelp()
WinHelp 0, "c:\excel\macrofun.hlp", HELP_CONTENTS, ""
WinHelp 0, "c:\excel\macrofun.hlp", HELP_QUIT, ""
End Sub
'-----------------------------------------------------------------------
'RUNHELPMACRO PROCEDURE
'Executes a Help macro.
'dwdata is a string that contains a Help macro to be executed.
'-----------------------------------------------------------------------
Sub RunHelpMacro()
WinHelp 0, "c:\excel\macrofun.hlp", HELP_CONTENTS, ""
WinHelp 0, "c:\excel\macrofun.hlp", HELP_COMMAND, "CopyDialog()"
End Sub
For more information about using the Windows API:
"Microsoft Windows 3.1 Software Development Kit"
For more information regarding creating custom help files:
"Microsoft Windows 3.1 Programming Tools", Microsoft Press, pages 21-66
Additional query words: 5.00c
Keywords : kbcode kbprg
Version : WINDOWS:5.0,5.0c
Platform : WINDOWS
Issue type :
Last Reviewed: June 28, 1999