Has anyone ran across a way to implement help files in a program? I'm trying to learn...
Printable View
Has anyone ran across a way to implement help files in a program? I'm trying to learn...
A program called VB-HelpWriter is avalible to create help files for VB, otherwise, download the Microsoft Help Workshop or the Microsoft HTML Help Workshop from MSDN.
VB-HelpWriter creates code automaticly. The other option means you must create you own code(use the API and HelpFile/Help Context Properties)
i recomend using VB-HelpWriter
Here's how I did mine. It is the first and only thatI have ever done, so there are undoubtedly more efficient and effective ways of doing it. I will leave it up to the gurus to explain other ways.
1) I made the help file in the Help Workshop, found under
Microsoft Visual Studio 6.0 Tools if you have it
installed. You can use the Help here to learn how to build it.
2) I set the project's Help File Name to the help file by
opening the project's Properties window and entering the route
3) I assign the route to a public variable
4) to call it from a messagebox, do this:Code:HelpFilePath = App.Path & "\Help\HelpFile.hlp"
5) to launch the help at the main menu, I put this codeCode:
MsgBox LoadResString(118), vbInformation + vbMsgBoxHelpButton, , HelpFilePath, 13
that I found here on VB World in a module:
and then I call it like this:Code:Option Explicit
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
Code:Private Sub mnuShowHelp_Click()
On Error GoTo Help_Error
'generate error if help file does not exist
If HelpFileExists = False Then
MsgBox LoadResString(121), vbCritical
Exit Sub
End If
WinHelp hwnd, HelpFilePath, HELP_TAB, 0
Exit Sub
Help_Error:
MsgBox "Help is not available at this time. Please " & _ "notify the system adminstrator.", vbCritical
End Sub
Especially Gringo for the code