Using the Help API
Public Declare Function WinHelp Lib _ "user32" Alias "WinHelpA" _ (ByVal hwnd As Long, ByVal _ lpHelpFile As String, _ ByVal wCommand As enm_wCommand, _ ByVal dwData As Long) As Long Public Declare Function WinHelpString _ Lib "user32" Alias "WinHelpA" _ (ByVal hwnd As Long, ByVal _ lpHelpFile As String, _ ByVal wCommand As enm_wCommand, _ ByVal strData As String) As Long Public Declare Function WinHelpStruct _ Lib "user32" Alias "WinHelpA" _ (ByVal hwnd As Long, ByVal _ lpHelpFile As String, _ ByVal wCommand As enm_wCommand, _ ByRef udtData As Any) As Long Public Enum enm_wCommand HELP_CONTEXT = &H1& HELP_QUIT = &H2& HELP_CONTENTS = &H3& HELP_INDEX = &H3& HELP_HELPONHELP = &H4& HELP_SETCONTENTS = &H5& HELP_SETINDEX = &H5& HELP_CONTEXTPOPUP = &H8& HELP_FORCEFILE = &H9& HELP_CONTEXTMENU = &HA& HELP_FINDER = &HB& HELP_WM_HELP = &HC& HELP_SETPOPUP_POS = &HD& HELP_FORCE_GID = &HE& HELP_TAB = &HF& HELP_KEY = &H101& HELP_COMMAND = &H102& HELP_PARTIALKEY = &H105& HELP_MULTIKEY = &H201& HELP_SETWINPOS = &H203& End Enum Public Type MULTIKEYHELP mkSize As Long mkKeylist As Byte szKeyphrase As String * 253 ' Array length is arbitrary; may be changed End Type Public Type HELPWININFO wStructSize As Long left As Long top As Long width As Long height As Long state As enm_windowstate rgchMember As String * 2 End Type Public Enum enm_windowstate SW_HIDE = 0& SW_SHOWNORMAL = 1& SW_SHOWMINIMIZED = 2& SW_SHOWMAXIMIZED = 3& SW_SHOWNOACTIVATE = 4& SW_SHOW = 5& SW_MINIMIZE = 6& SW_SHOWMINNOACTIVE = 7& SW_SHOWNA = 8& SW_RESTORE = 9& End Enum
I have included type-safe declarations so that we can pass strings and UDTs. The WinHelp call has these parameters:
hwnd | Handle of the window requesting Help. The WinHelp function uses this handle to keep track of which programs have requested Help. If wCommand specifies HELP_CONTEXTMENU, hwnd identifies the control requesting Help. |
lpHelpFile | The name of the Help file that WinHelp is to display. The filename may be followed by an angle bracket (>) and the name of a secondary window if the topic is to be displayed in a secondary window rather than in the primary window. The name of the secondary window must have been defined previously in the [WINDOWS] section of the Help Project (.HPJ) file. |
wCommand | Type of help requested. For a list of possible values and how they affect the value to place in the dwData parameter, see below. |
xxxData | Additional data. The value used depends on the value of the wCommand parameter. For a list of possible values, click here. |
Page 2 of 5
This article was originally published on November 20, 2002