Library tutorials & articles
Creating HTML Help
Displaying help
In order to use HTML help in your application, you need to add the following code into a module:
' Visual Basic code for implementing HTML Help 1.1
'*****
' Declare the following two constants
' as PUBLIC
Public Const HH_HELP_CONTEXT = &HF
' display mapped numeric
Public Const HH_TP_HELP_WM_HELP = &H11
' text popup help, same as
' WinHelp HELP_WM_HELP
Private Const HH_DISPLAY_TOPIC = &H0
Private Const HH_HELP_FINDER = &H0
' WinHelp equivalent
Private Const HH_DISPLAY_TOC = &H1
' WinHelp equivalent
Private Const HH_DISPLAY_INDEX = &H2
' WinHelp equivalent
Private Const HH_DISPLAY_SEARCH = &H3
' not currently implemented
Private Const HH_SET_WIN_TYPE = &H4
Private Const HH_GET_WIN_TYPE = &H5
Private Const HH_GET_WIN_HANDLE = &H6
Private Const HH_ENUM_INFO_TYPE = &H7
' Get Info type name, call
' repeatedly to enumerate,
' -1 at end
Private Const HH_SET_INFO_TYPE = &H8
' Add Info type to filter.
Private Const HH_SYNC = &H9
Private Const HH_ADD_NAV_UI = &HA
' not currently implemented
Private Const HH_ADD_BUTTON = &HB
' not currently implemented
Private Const HH_GETBROWSER_APP = &HC
' not currently implemented
Private Const HH_KEYWORD_LOOKUP = &HD
Private Const HH_DISPLAY_TEXT_POPUP = &HE ' display string
resource id
' or text in a popup window
' value in dwData
Private Const HH_TP_HELP_CONTEXTMENU = &H10 ' text popup help, same
as
' WinHelp HELP_CONTEXTMENU
Private Const HH_CLOSE_ALL = &H12
' close all windows opened
' directly or indirectly by
' the caller
Private Const HH_ALINK_LOOKUP = &H13
' ALink version of
' HH_KEYWORD_LOOKUP
Private Const HH_GET_LAST_ERROR = &H14
' not currently implemented
Private Const HH_ENUM_CATEGORY = &H15
' Get category name, call
' repeatedly to enumerate,
' -1 at end
Private Const HH_ENUM_CATEGORY_IT = &H16 ' Get category
info type
' members, call repeatedly to
' enumerate, -1 at end
Private Const HH_RESET_IT_FILTER = &H17 '
Clear the info type filter
' of all info types.
Private Const HH_SET_INCLUSIVE_FILTER = &H18 ' set inclusive filtering
' method for untyped topics
' to be included in display
Private Const HH_SET_EXCLUSIVE_FILTER = &H19 ' set method for untyped
' topics to be excluded from
' the display
Private Const HH_SET_GUID = &H1A
' For Microsoft Installer --
' dwData is a pointer to the
' GUID string
Private Const HH_INTERNAL = &HFF
' Used internally.
' Button IDs
Private Const IDTB_EXPAND = 200
Private Const IDTB_CONTRACT = 201
Private Const IDTB_STOP = 202
Private Const IDTB_REFRESH = 203
Private Const IDTB_BACK = 204
Private Const IDTB_HOME = 205
Private Const IDTB_SYNC = 206
Private Const IDTB_PRINT = 207
Private Const IDTB_OPTIONS = 208
Private Const IDTB_FORWARD = 209
Private Const IDTB_NOTES = 210
' not implemented
Private Const IDTB_BROWSE_FWD = 211
Private Const IDTB_BROWSE_BACK = 212
Private Const IDTB_CONTENTS = 213
' not implemented
Private Const IDTB_INDEX = 214
' not implemented
Private Const IDTB_SEARCH = 215
' not implemented
Private Const IDTB_HISTORY = 216
' not implemented
Private Const IDTB_BOOKMARKS = 217
' not implemented
Private Const IDTB_JUMP1 = 218
Private Const IDTB_JUMP2 = 219
Private Const IDTB_CUSTOMIZE = 221
Private Const IDTB_ZOOM = 222
Private Const IDTB_TOC_NEXT = 223
Private Const IDTB_TOC_PREV = 224
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type tagHHN_NOTIFY
hdr As Variant
pszUrl As String
' Multi-byte, null-terminated string
End Type
Private Type tagHH_POPUP
cbStruct As Integer
' sizeof this structure
hinst As Variant
' instance handle for string resource
idString As Variant
' string resource id, or text id if pszFile
' is specified in HtmlHelp call
pszText As String
' used if idString is zero
pt As Integer
' top center of popup window
clrForeground As ColorConstants
' use -1 for default
clrBackground As ColorConstants
' use -1 for default
rcMargins As RECT
' amount of space between edges of window and
' text, -1 for each member to ignore
pszFont As String
' facename, point size, char set, BOLD ITALIC
' UNDERLINE
End Type
Private Type tagHH_AKLINK
cbStruct As Integer
' sizeof this structure
fReserved As Boolean
' must be FALSE (really!)
pszKeywords As String
' semi-colon separated keywords
pszUrl As String
' URL to jump to if no keywords found (may be
' NULL)
pszMsgText As String
' Message text to display in MessageBox if
' pszUrl
' is NULL and no keyword match
pszMsgTitle As String
' Message text to display in MessageBox if
' pszUrl is NULL and no keyword match
pszWindow As String
' Window to display URL in
fIndexOnFail As Boolean
' Displays index if keyword lookup fails.
End Type
Private Enum NavigationTypes
HHWIN_NAVTYPE_TOC
HHWIN_NAVTYPE_INDEX
HHWIN_NAVTYPE_SEARCH
HHWIN_NAVTYPE_BOOKMARKS
HHWIN_NAVTYPE_HISTORY ' not implemented
End Enum
Private Enum IT
IT_INCLUSIVE
IT_EXCLUSIVE
IT_HIDDEN
End Enum
Private Type tagHH_ENUM_IT
cbStruct As Integer
' size of this structure
iType As Integer
' the type of the information type i.e.
' Inclusive, Exclusive, or Hidden
pszCatName As String
' Set to the name of the Category to
' enumerate the info types in a category;
' else NULL
pszITName As String
' volitile pointer to the name of the
' infotype. Allocated by call. Caller
' responsible for freeing
pszITDescription As String
' volitile pointer to the description of the
' infotype.
End Type
Private Type tagHH_ENUM_CAT
cbStruct As Integer
' size of this structure
pszCatName As String
' volitile pointer to the category name
pszCatDescription As String
' volitile pointer to the category
' description
End Type
Private Type tagHH_SET_INFOTYPE
cbStruct As Integer
' the size of this structure
pszCatName As String
' the name of the category, if any, the
' InfoType is a member of.
pszInfoTypeName As String
' the name of the info type to add to the
' filter
End Type
Private Enum NavTabs
HHWIN_NAVTAB_TOP
HHWIN_NAVTAB_LEFT
HHWIN_NAVTAB_BOTTOM
End Enum
Private Const HH_MAX_TABS = 19 ' maximum number of tabs
Private Enum Tabs
HH_TAB_CONTENTS
HH_TAB_INDEX
HH_TAB_SEARCH
HH_TAB_BOOKMARKS
HH_TAB_HISTORY
End Enum
' HH_DISPLAY_SEARCH Command Related Structures and Constants
Private Const HH_FTS_DEFAULT_PROXIMITY = (-1)
Private Type tagHH_FTS_QUERY
cbStruct As Integer
' Sizeof structure in bytes.
fUniCodeStrings As Boolean
' TRUE if all strings are unicode.
pszSearchQuery As String
' String containing the search query.
iProximity As Long
' Word proximity.
fStemmedSearch As Boolean
' TRUE for StemmedSearch only.
fTitleOnly As Boolean
' TRUE for Title search only.
fExecute As Boolean
' TRUE to initiate the search.
pszWindow As String
' Window to display in
End Type
' HH_WINTYPE Structure
Private Const SW_MAXIMIZE = 3
Private Const SW_MINIMIZE = 6
Private Const SW_NORMAL = 1
Private Const SW_SHOW = 5
Private Type HH_WINTYPE
cbStruct As Integer
' IN: size of this structure including all
' Information Types
fUniCodeStrings As Boolean
' IN/OUT: TRUE if all strings are in UNICODE
pszType As String
' IN/OUT: Name of a type of window
fsValidMembers As Variant
' IN: Bit flag of valid members
' (HHWIN_PARAM_)
fsWinProperties As Variant
' IN/OUT: Properties/attributes of the window
' (HHWIN_)
pszCaption As String
' IN/OUT: Window title
dwStyles As Variant
' IN/OUT: Window styles
dwExStyles As Variant
' IN/OUT: Extended Window styles
rcWindowPos As RECT
' IN: Starting position, OUT: current
' position
nShowState As Integer
' IN: show state (e.g., SW_SHOW)
hwndHelp As Variant
' OUT: window handle
hwndCaller As Variant
' OUT: who called this window
' The following members are only valid if
' HHWIN_PROP_TRI_PANE is set
hwndToolBar As Variant
' OUT: toolbar window in tri-pane window
hwndNavigation As Variant
' OUT: navigation window in tri-pane window
hwndHTML As Variant
' OUT: window displaying HTML in tri-pane
' window
iNavWidth As Integer
' IN/OUT: width of navigation window
rcHTML As RECT
' OUT: HTML window coordinates
pszToc As String
' IN: Location of the table of contents file
pszIndex As String
' IN: Location of the index file
pszFile As String
' IN: Default location of the html file
pszHome As String
' IN/OUT: html file to display when Home
' button is clicked
fsToolBarFlags As Variant
' IN: flags controling the appearance of the
' toolbar
fNotExpanded As Boolean
' IN: TRUE/FALSE to contract or expand, OUT:
' current state
curNavType As Integer
' IN/OUT: UI to display in the navigational
' pane
tabpos As Integer
' IN/OUT: HHWIN_NAVTAB_TOP, HHWIN_NAVTAB_LEFT,
' or HHWIN_NAVTAB_BOTTOM
idNotify As Integer
' IN: ID to use for WM_NOTIFY messages
tabOrder(HH_MAX_TABS + 1) As Byte
' IN/OUT: tab order: Contents, Index,
' Search, History, Favorites, Reserved 1-5,
' Custom tabs
cHistory As Integer
' IN/OUT: number of history items to keep
' (default is 30)
pszJump1 As String
' Text for HHWIN_BUTTON_JUMP1
pszJump2 As String
' Text for HHWIN_BUTTON_JUMP2
pszUrlJump1 As String
' URL for HHWIN_BUTTON_JUMP1
pszUrlJump2 As String
' URL for HHWIN_BUTTON_JUMP2
rcMinSize As RECT
' Minimum size for window (ignored in version
' 1 of the Workshop)
cbInfoTypes As Integer
' size of paInfoTypes;
End Type
Private Enum Actions
HHACT_TAB_CONTENTS
HHACT_TAB_INDEX
HHACT_TAB_SEARCH
HHACT_TAB_HISTORY
HHACT_TAB_FAVORITES
HHACT_EXPAND
HHACT_CONTRACT
HHACT_BACK
HHACT_FORWARD
HHACT_STOP
HHACT_REFRESH
HHACT_HOME
HHACT_SYNC
HHACT_OPTIONS
HHACT_PRINT
HHACT_HIGHLIGHT
HHACT_CUSTOMIZE
HHACT_JUMP1
HHACT_JUMP2
HHACT_ZOOM
HHACT_TOC_NEXT
HHACT_TOC_PREV
HHACT_NOTES
HHACT_LAST_ENUM
End Enum
Private Type tagHHNTRACK
hdr As Variant
pszCurUrl As String
' Multi-byte, null-terminated string
idAction As Integer
' HHACT_ value
phhWinType As HH_WINTYPE
' Current window type structure
End Type
Public Type HH_IDPAIR
dwControlId As Long
dwTopicId As Long
End Type
Public Declare Function htmlhelp Lib "hhctrl.ocx" _
Alias "HtmlHelpA" (ByVal hwnd As Long, _
ByVal lpHelpFile As String, _
ByVal wCommand As Long, _
ByVal dwData As Long) As Long
Then, you need to add a procedure that will set the HTML file path:
Public Function SetHTMLHelpStrings() As String
'// this presumes the help file is in the same directory
as your app, and Main is the name of the window
SetHTMLHelpStrings = App.Path & "\TestHTMLHelp.chm"
& ">Main"
End Function
To display the contents, use this code (from a form, otherwise you will need to change the hwnd value that is passed):
Public Sub HTMLHelpContents()
' Force the Help window to display
' the Contents file (*.hhc) in the left pane
htmlhelp hwnd, SetHTMLHelpStrings(), HH_DISPLAY_TOC, 0
End Sub
To display the index, use this code (from a form, otherwise you will need to change the hwnd value that is passed):
Public Sub HTMLHelpIndex()
' Force the Help window to display the Index file
' (*.hhk) in the left pane
htmlhelp hwnd, SetHTMLHelpStrings(), HH_DISPLAY_INDEX, 0
End Sub
To display a specific topic, using a filename this code (from a form, otherwise you will need to change the hwnd value that is passed):
Public Sub HTMLShowTopic(strTopic As String)
' Force the Help window to load a specific topic.
' The Help window will synchronize the
' Contents display automatically
htmlHelp hwnd, SetHTMLHelpStrings(), HH_DISPLAY_TOPIC, strTopic
End Sub
To call it , use this code:
HTMLShowTopic "html\test_topic_1.htm"
To display a specific topic, using a context id (from a form, otherwise you will need to change the hwnd value that is passed):
Public Sub HTMLShowTopic(lngTopicID As Long)
' Force the Help window to load a specific topic.
' The Help window will synchronize the
' Contents display automatically
htmlHelp hwnd, SetHTMLHelpStrings(), HH_HELP_CONTEXT, lngTopicID
End Sub
To call it , use this code:
HTMLShowTopic 1000 '// 1000 = Context ID
At the moment, you cannot display the Search tab automatically from VB
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Absolutely wonderful - before finding this I've spent hours trying to pick my way through this topic - thanks
!--removed tag-->hi,
i sent u how retrive the file
if you want how to create and the rest of the process, pls give some time
bye
HI, i found this is the one of of the way we can creat and its very simple;
System.Diagnostics.Process process = new System.Diagnostics.Process();process.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + "Urfile.chm";process.Start();
This will work definitely.
BYE
Hi. I went through your tutorial on creating HTML Help, but keep running into a very basic problem. After compiling the help file for the first time and opening up the chm file, my home.htm file does not display at all in the right window. I get the help file window (with the HIDE, BACK, FORWARD, etc. displayed, but the window on the right is blank. I followed your tutorial step by step, saved the html files in the directories as indicated, etc. What am I doing wrong? I receive no error messages or security warnings. Thanks in advance!
Can you give me any detail or any url where I can find about how to create chm files programmatically using C#??
Thanks in Advance
Nilesh Gambhava
i have tried to make popup in html help but coudn't. can somebody help.
I have kinda the same problem. Showing a topic works for me if the pages are within the chm file, however, if a topic is on a web site,
even though I can retrieve them by ciking on them, with the HtmlHelp function, both using HHDISPLAYTOPIC and HHHELPCONTEXT..
the help viewer jumps to the topic, but fails retrieving the page on the content pane. It does seem to synchronize, it doesn shange the content pane, but to a bad page, like it wants it to be within it.. or I don't really know. So please please, someone help me! you know what to do? have seen this?
Hi, I read your entire article and it really helped a lot but I can't wrap up what I've made because for some reason the help file just won't show.
Private Sub mnuHelpHowto_Click()
HTMLShowTopic 1030
End Sub
...
Public Sub HTMLShowTopic(lngTopicID As Long)
' Force the Help window to load a specific topic.
' The Help window will synchronize the
' Contents display automatically
htmlhelp hwnd, App.helpfile & ">Main", HHDISPLAYTOPIC, lngTopicID
End Sub
I don't quite understand why it will not show the help file, my comp appears to be processing something but in the end it does not show the help file. If I specify 0 as the lngTopicID it does show the window but at the default topic, not the topic I want it to show. FYI I have mapped the numbers to a file using the notepad trick.
Great I can use this now I understand it!
Well Done!
I followed the article and it fixed many of my problems but ...
I'm having problems displaying popup text with textboxes.
'No help ID matches control ID #...
Iv'e tested the popup text files outside the app and they're find. My code works with command buttons (only?).
Any ideas??
Excellent topic! this is very helpful, thanks a lot. It has been a great jumpstart for integrating html help file in VB. Hope you can include topics on popups.
Yes i do still have this problem.
Thankyou for your responce, unfortunatly i still cannot resolve my problem.
I have looked through some of the links you posted and i will look at the others in more detail when i have more time.
Thanks again.
Stevesoft,
In the unlikely event that you're still struggling with this problem...
> I have followed this tutorial and have the following problem:
>
> The code for displaying the contents or the index only works after i
> have pressed F1 to display help.
>
> Once i have done this once, the code works fine...... why is this?
The following are the principal documents on connecting HTML Help to an application. Maybe these will help.
http://www.smountain.com/mProgrammingHelp.htm (VB, C++)
http://www.mvps.org/htmlhelpcenter/mapping.htm
http://www.mvps.org/htmlhelpcenter/whcomplete.htm (VB)
http://www.workwrite.com/helpthink/vbliske.htm (VB)
http://helpware.net/delphi/index.html (Delphi)
http://www.workwrite.com/helpthink/delphi_chandler.htm (Delphi)
Pete
rollershade,
Just came across your message. Here's a very belated follow-up, in the unlikely event you still need this information.
> the ordinal 373 could not be located in the dynamic link library HHA.dll
Make sure that all the HTML Help runtime DLLs are properly installed and registered, using either:
HTML Help DLL Registrar (http://www.helpfulsolutions.com/)
MJ's Help Diagnostics (http://helpware.net/downloads/index.htm)
> the link u gave for the microsoft page cant be found
This was changed a little while ago to http://msdn.microsoft.com/library/en-us/htmlhelp/html/vsconHH1Start.asp.
Pete
i have installed it from the vb6 cd , but i try and run the html workshop, and i get this error
the ordinal 373 could not be located in the dynamic link library HHA.dll
any ideas, and the link u gave for the microsoft page cant be found
The code for displaying the contents or the index only works after i have pressed F1 to display help.
Once i have done this once, the code works fine...... why is this?
Stevesoft
This thread is for discussions of Creating HTML Help.