These Form events occur when F1 is pressed or when the What's This mouse cursor [?] is clicked.
Sub Form_OnHelp([index%,] Flg%, ID%, hWnd%, Ctx%, x%, y%)
Sub Form_OnCtrlHelp([index%,] Ctrl As Object, x%, y%)
Sub Form_OnMenuHelp([index%,] idx%, x%, y%)
These events occur when F1 is pressed or when the What's This mouse cursor [?] is clicked. The OnHelp event is called for non-Ocx objects and OnCtrlHelp for Ocx objects. The OnMenuHelp event occurs when the mouse is over a menu entry and F1 is pressed. It is also possible to use an on screen control or program code to switch on the What's This mouse cursor by setting the the WhatsThisMode property of the window itself.
If the help is required for an Ocx child window, the Form receives an OnCtrlHelp event specifying the Ocx control and the mouse coordinates in the arguments of the event. To identify the help associated with the Ocx object set the WhatsThisHelpID or the HelpContextID properties with a value.
When the help is required for a normal control the OnHelp event is executed passing the following arguments:
Flg% | Type of context for which Help is requested. This can be one of HELPINFO_MENUITEM - Help requested for a menu item. HELPINFO_WINDOW - Help requested for a control or window. |
ID% | Identifier of the child window or control. |
hWnd% | Window handle of the control. |
Ctx% | Help context identifier of the window or control set with SetWindowContextHelpId(h, id) API function. |
x%, y% | The screen coordinates of the mouse cursor. This is useful for providing Help based on the position of the mouse cursor. |
To identify the help associated with a control object set a value using SetWindowContextHelpId(h, id) API function (equivalent to the WhatsThisHelpID or the HelpContextID properties).
When the mouse is over a menu entry and F1 is pressed, the OnMenuHelp event sub is invoked, identifying the currently selected menu item in idx% and the mouse coordinates in x% and y%.
To show the relevant help page in a WinHelp (.hlp) file use the ShowHelp; for a HTMLHelp (.chm) file, see Accessing HTML Help Files.
// If you a calling the WinHelp (.hlp) file, set winhelp? to True
Dim winhelp? = False
OpenW 1
Win_1.MinButton = False : Win_1.MaxButton = False : Win_1.HelpButton = True
If winhelp?
Ocx CommDlg cd : cd.HelpFile = "gfawin32.hlp"
Else
Declare Function HTMLHelpTopic Lib "hhctrl.ocx" Alias "HtmlHelpA" (ByVal hwndCaller As Long, ByVal pszFile As String, ByVal uCommand As Long, ByVal dwData As String) As Long
Global helpdir$ = GetSetting("\\HKEY_CLASSES_ROOT\Applications\GfaWin32.exe\shell\open\command", , "")
helpdir$ = Left(helpdir$, RInStr(helpdir$, "\")) & "GFAWin32.chm" : If Left(helpdir$, 1) = #34 Then helpdir$ = Mid(helpdir$, 2)
Global Const HH_DISPLAY_INDEX = &H2
EndIf
Dim m$()
Array m$() = "File"#10 "Exit"#10#10
Menu m$()
Ocx Command cmd = "Push", 10, 10, 80, 24
cmd.WhatsThisHelpID = 1002
PushButton "Button", 100, 10, 40, 80, 24
// Give a normal control a WhatsThisHelpID:
~SetWindowContextHelpId(Dlg(-1, 100), 1003)
LocaXY 1, 10
Do
Sleep
Until Me Is Nothing
Sub Win_1_OnCtrlHelp(Ctrl As Object, x%, y%)
Debug.Print "OnCtrlHelp: WhatsThisHelpID = "; Ctrl.WhatsThisHelpID
If winhelp?
cd.HelpContext = Ctrl.WhatsThisHelpID
cd.HelpCommand = cdhContext
cd.ShowHelp
Else
HTMLHelpDisplay(Ctrl.WhatsThisHelpID)
EndIf
EndSub
Sub Win_1_OnHelp(Flg%, ID%, hWnd%, Ctx%, x%, y%)
Debug.Print "OnHelp: Ctx = "; Ctx
If winhelp?
cd.HelpContext = Ctx
cd.HelpCommand = cdhContext
cd.ShowHelp
Else
HTMLHelpDisplay(Ctx%)
EndIf
EndSub
Sub Win_1_OnMenuHelp(idx%, x%, y%)
Debug.Print "OnMenuHelp: idx% = "; idx ` Me.MenuItem(idx).Text
If winhelp?
cd.HelpContext = idx%
cd.HelpCommand = cdhContext
cd.ShowHelp
Else
HTMLHelpDisplay(idx%)
EndIf
EndSub
Sub HTMLHelpDisplay(helpvalue%)
Local HHhWnd As Int32
// At the time of writing, this help file does not have ContextIDs
// Use the returned WhatsThisHelpID as a pointer as below
Select helpvalue%
Case 1
HHhWnd = HTMLHelpTopic(Null, helpdir$, HH_DISPLAY_INDEX, "menu")
Case 1002
HHhWnd = HTMLHelpTopic(Null, helpdir$, HH_DISPLAY_INDEX, "command")
Case 1003
HHhWnd = HTMLHelpTopic(Null, helpdir$, HH_DISPLAY_INDEX, "pushbutton")
EndSelect
~SetForegroundWindow(HHhWnd) : SendKeys #13
EndSub
{Created by Sjouke Hamstra; Last updated: 17/07/2015 by James Gaite}