Contents Index Topic Contents |
HTMLHelp API Reference
The HtmlHelp API currently resides in the file HTMLHELP.DLL, however this is very likely to be moved to a different DLL before HTML Help ships. If you are not using GetProcAddress to get a pointer to the HtmlHelp function, then you must plan on changing the library you link to.
The functionality provided by the HtmlHelp API resides in the file HHCTRL.OCX. Because this functionality requires loading various other DLLs such as ole32.dll, the API itself resides in a DLL that requires no additional DLLs to be loaded. Only when the API is actually called will ole32 and other DLLs be loaded.
The HtmlHelp API is modeled after the WinHelp API function to make it easy to convert existing programs to use HTML Help instead of WinHelp to display their help. By the time HTML Help ships, there will also be an IHHWindow interface that can be used in place of the HtmlHelp API. This can be used by programs that already load OLE32.DLL or by programs like Visual Basic.
In its simplest form, the HtmlHelp API creates a child window which in turn hosts SHDOCVW and displays the HTML file you specify. The window is a child of whatever parent window you specify, and will automatically stay on top of that parent window, and close when the parent window is closed. You can also take complete control of the window-creation process by defining the window styles, coordinates, caption, and display state. This means you can embed SHDOCVW even in a non-OLE activated program.
SYNTAX
HWND HtmlHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData);
- hwndCaller
- Specifies the handle of the window calling the HtmlHelp API. If the HtmlHelp API call results in messages being sent from the HTML Help window, they will be sent to this window handle.
- pszFile
- Specifies an HTML file, a URL, a compiled HTML file, or a window definition (preceeded with a ‘>’ character). If the command being used does not require a file or URL, this value may be NULL.
- uCommand
- Specifies the action to perform. See the Comments section for details.
- dwData
- Specifies any data that may be required based on the value of the uCommand parameter.
Comments
The uCommand parameter determines what action to take, and what needs to be supplied for the pszFile and dwData parameters. The following table lists the commands, actions, and required parameters:
Command Description pszFile dwData HH_DISPLAY_TOPIC Displays an HTML file. If a window type is not specified, a default window type is used. If the window type or default window type is already being displayed, the HTML file will replace what is currently being displayed. File, URL, or compiled HTML file. If the greater then character (>) is used, it must be followed by the name of the window type to display the topic in. May be zero or a pointer to a File, URL, or compiled HTML file. This parameter may be a pointer to a filename within a compiled HTML file if the pszFile parameter points to that compiled HTML file. HH_DISPLAY_TEXT_POPUP Displays text from a string resource, text string, or text file in a popup window. Text filename if text resides in a file. Use NULL if the text is in a string resource id or specified in the HH_POPUP structure. Points to a HH_POPUP structure. HH_SET_WIN_TYPE Creates a new window type, or modifies an existing window type. Ignored. Points to a HH_WINTYPE structure. HH_GET_WIN_TYPE Retrieves the HH_WINTYPE structure associated with a window type. If the window type has not been specified, the return value is -1. If the window type has been specified, the return value is the handle of the window (NULL if the window hasn’t been created). Specifies the name of the window. The window name must begin with a ‘>’ character, and may optionally be preceded by the name of the compiled HTML file. Points to the address of a PHH_WINTYPE pointer. Do not modify the structure this pointer points to. HH_GET_WIN_HANDLE Retrieves the handle of the window associated with the specified window type. If the window type has not been created, the return value is NULL. Ignored Pointer to the name of the window type. HH_SET_INFO_TYPES Sets all the information types to be used in a window. In a tri-pane window, this will cause the navigation pane to redraw (if currently displayed) to reflect any changes in the Information Types being used. Ignored. Points to a HH_WINTYPE structure. The cbStruct and ainfoTypes members must be filled in. HH_SET_INFO_TYPES Sets all the hidden information types to be used in a window. This command will not affect any Information Types chosen by the user. In a tri-pane window, this will cause the navigation pane to redraw (if currently displayed) to reflect any changes in the Information Types being used. Ignored. Points to a HH_WINTYPE structure. The cbStruct and ainfoTypes members must be filled in. HH_SYNC Synchronizes the Table of Contents of a tri-pane window with the specified URL. This should only be used with windows thatwhich are not auto-syncnchronized. Specifies the name of the window to sychronizesynchronize. Specifies the URL to synchronize with. This URL does not need to be currently displayed... HH_ADD_NAV_UI Adds a navigational window to use in the navigational pane of a tri-pane window. Address of an HhWinCallBack function to support the new UI. Unique numeric value representing the UI. The UI may be switched to by specifying this value in the curNavType member of the HH_WINTYPE structure. HH_ADD_BUTTON Adds a button to the toolbar of a tri-pane window. Address of an HhWinCallBack function to support the button. Unique numeric value representing the button. HH_KEYWORD_LOOKUP Attempts to find the given keyword in a .HHK file. If found, the topic is displayed in the specified (or current, if not specified) window. If NULL, the .HHK file associated with the current window is used. If a string containing a window definition is used, but not a .HHK file, then the .HHK from the specified window is used, and if the topic is found, it will be displayed in that window. If a .HHK file is specified, that file will be used. Points to a string containing one or more keywords,keywords separated by a semi-colon. HH_WINTYPE structure
Window types may be defined by an author and stored in a compiled HTML file, or they may be defined by a program by using the HtmlHelp API. Each window type should have a unique name. If a call to the HtmlHelp API is made specifying a window type that does not exist, then a type will be created using the indicated type name, but with default properties. When creating, modifying, or retrieving a window type, the HH_WINTYPE structure is used. The following describes this structure:
typedef struct tagHH_WINTYPE {
int cbStruct; // IN: size of this structure including all Information Types
BOOL fUniCodeStrings; // IN/OUT: TRUE if all strings are in UNICODE
LPCTSTR pszType; // IN/OUT: Name of a type of window
DWORD fsValidMembers; // IN: Bit flag of valid members (HHWIN_PARAM_)
DWORD fsWinProperties; // IN/OUT: Properties/attributes of the window (HHWIN_)
LPCTSTR pszCaption; // IN/OUT: Window title
DWORD dwStyles; // IN/OUT: Window styles
DWORD dwExStyles; // IN/OUT: Extended Window styles
RECT rcWindowPos; // IN: Starting position, OUT: current position
int nShowState; // IN: show state (e.g., SW_SHOW)
HWND hwndHelp; // OUT: window handle
HWND hwndCaller; // OUT: who called this window
HH_INFOTYPE* paInfoTypes; // IN: Pointer to an array of Information Types
// The following members are only valid if HHWIN_PROP_TRI_PANE is set
HWND hwndToolBar; // OUT: toolbar window in tri-pane window
HWND hwndNavigation; // OUT: navigation window in tri-pane window
HWND hwndHTML; // OUT: window displaying HTML in tri-pane window
int iNavWidth; // IN/OUT: width of navigation window
RECT rcHTML; // OUT: HTML window coordinates
LPCTSTR pszToc; // IN: Location of the table of contents file
LPCTSTR pszIndex; // IN: Location of the index file
LPCTSTR pszFile; // IN: Location of the html file
LPCTSTR pszHome; // IN/OUT: html file to display when Home button is clicked
DWORD fsToolBarFlags; // IN: flags controlingcontrolling the appearance of the toolbar
BOOL fExpanded; // IN: TRUE/FALSE to expand or contract, OUT: current state
int curNavType; // IN/OUT: UI to display in the navigational pane
int tabpos; // IN/OUT: NAVTAB_TOP, NAVTAB_LEFT, or NAVTAB_BOTTOM
int idNotify; // IN: ID to use for WM_NOTIFY messages
BYTE tabOrder[HH_MAX_TABS + 1]; // IN/OUT: tab order: Contents, Index, Search, History, Favorites, Reserved 1-5, Custom tabs
} HH_WINTYPE;
Member Description cbStruct Specifies the size of the structure. This value must always be filled in before passing the structure to the HtmlHelp API. fUniCodeStrings Specifies whether the strings used in this structure are UNICODE or not. pszType Specifies a null-terminated string containing the name of the window type. fsValidMembers Specifies which members in the structure are valid. See the following Comments section for a description of this member. fsWinProperties Specifies the properties of the window. See the following Comments section for a description of this member. pszCaption Specifies a null-terminated string contain the caption to display in the title bar of the window. dwStyles Specifies the styles used to create the window. These styles may be ignored, combined with default styles, or used exclusively depending on the value of fsValidMembers and fsWinProperties. dwExStyles Specifies the extended styles used to create the window. These styles may be ignored, combined with default styles, or used exclusively depending on the value of fsValidMembers and fsWinProperties. rcWindowPos Specifies the coordinates of the window. When setting this value, any negative member will be ignored. For example, to change the position, but not the width and height, the left and top positions would be set and the right and bottom RECT members would be set to -1. nShowState Specifies the initial display state of the window. hwndHelp Specifies the handle of the window if the window has been created. hwndCaller Specifies the window to send messages to. paInfoTypes This specifies the Information Types to display. Each Information Type is a bit flag, with bit zero indicating whether or not all Information Types should be shown. If bit zero is not set, then all HTML Help commands that use Information Types will this information to determine what navigational UI should be displayed, and where hyperlinks should jump to. hwndToolBar Specifies the handle of the window containing the toolbar in a tri-pane window. hwndNavigation Specifies the handle of the window containing the current navigation UI in a tri-pane window. hwndHTML Specifies the handle of the window that displays HTML files in a tri-pane window. This window is a host for SHDOCVW. iNavWidth Specifies the width of the navigation pane in a tri-pane window when the tri-pane window is expanded. rcHTML Specifies the coordinates of the HTML pane in a tri-pane window. pszToc In a tri-pane window, this specifies the file or URL to use for the Table of Contents. pszIndex In a tri-pane window, this specifies the file or URL to use for the Index. pszFile In a tri-pane window, this specifies the file or URL to display in the right pane. This file will be displayed if the user clicks the Home button in the toolbar. pszHome In a tri-pane window, this specifies the file or URL to display in the right pane when the Home button is clicked. fsToolBarFlags In a tri-pane window, this determines which buttons will be displayed in the toolbar pane. See the section below describing HHWIN_BUTTON constants. fExpanded In a tri-pane window, this determines whether or not the navigational pane is to be shown. curNavType Specifies which navigational UI is displayed in the navigational pane of a tri-pane window. tabpos Specifies where the tabs are to be placed in the navigational pane of a tri-pane window. The tabs may be set on the top, left or bottom. idNotify Specifies the ID to use as the WPARAM member of WM_NOTIFY messages. tabOrder Specifies the order that tabs appear in the navigation pane of a Tri-pane window. Set the HHWIN_PARAM_TABORDER flag if you use this member. The first ten positions are reserved for default HTML Help tabs: Contents, Index, Search, History, Favorites, and Reserved 1-5 (for future expansion). Each byte represents the numeric position, starting with zero. For example, to put the Index tab first and the Contents tab second, you would specify tabOrder[HH_TAB_CONTENTS] = 1, and tabOrder[HH_TAB_INDEX] = 0. cHistory Specifies the number of history items to keep. This member is currently ignored, but will be used in the future. pszJump1 Specifies the URL to jump to when the Jump1 button is clicked. pszJump1 Specifies the URL to jump to when the Jump2 button is clicked. The fsValidMembers member is used when modifying an existing window type, and determines which of the other members should be updated. This parameter may be a combination of one or more of the following values:
HHWIN_PARAM_PROPERTIES The fsWinProperties member is valid. HHWIN_PARAM_STYLES The dwStyles member is valid. HHWIN_PARAM_EXSTYLES The dwExStyles member is valid. HHWIN_PARAM_RECT The rcWindowPos member is valid. HHWIN_PARAM_NAV_WIDTH The rcNavigation member is valid. HHWIN_PARAM_SHOWSTATE The nShowState member is valid. HHWIN_PARAM_INFOTYPES The ainfoTypes member is valid. HHWIN_PARAM_TB_FLAGS The fsToolBarFlags member is valid. HHWIN_PARAM_EXPANSION The fExpanded member is valid. HHWIN_PARAM_TABPOS The tabpos member is valid HHWIN_PARAM_TABORDER The tabOrder member is valid. HHWIN_PARAM_HISTORY_COUNT The cHistory member is valid. The fsWinProperties member is used to define various properties for the window, and is also used to control how the window is created. This member may be a combination of one or more of the following values:
HHWIN_PROP_ONTOP Specifies that the window is to be kept on top of every window on the desktop instead of just being on top of the caller’s window. HHWIN_PROP_NOTITLEBAR Specifies that the window should not contain a title bar. HHWIN_PROP_NODEF_STYLES Specifies that no default styles should be used when creating the window. If this flag is not specified, a window will be created with the following default styles: WS_THICKFRAME | WS_OVERLAPPED | WS_VISIBLE
HHWIN_PROP_NODEF_EXSTYLES Specifies that no default extended styles should be used when creating the window. If this flag is used with the HHWIN_PROP_ONTOP flag, then the HHWIN_PROP_ONTOP flag will be ignored. HHWIN_PROP_TRI_PANE Specifies that a tri-pane window is to be created. Once a window has already been created, this flag cannot be used to change the existing window. HHWIN_PROP_NOTB_TEXT Specifies that the toolbar of a tri-pane window should not contain text underneath the buttons. HHWIN_PROP_POST_QUIT Specifies that when the help window is closed, a WM_QUIT message is posted to the calling programs message queue. This will normally cause the calling program to terminate. HHWIN_PROP_AUTO_SYNC Specifies that if the Contents or Index navigational pane is currently displayed, then if the user jumps to a different HTML file, the Contents or Index will scroll to the entry or keyword that points to the current URL. If the URL cannot be located in the current navigational pane, no action will be taken. HHWIN_PROP_TRACKING Specifies that tracking notification messages should be sent to the caller. HHWIN_PROP_TAB_SEARCH Specifies that a full-text search tab is to be included as one of the navigation panes in a tri-pane window. HHWIN_PROP_TAB_HISTORY Specified that a history tab is to be included as one of the navigation panes in a tri-pane window. This property is not supported in version 1. HHWIN_PROP_TAB_FAVORITES Specifies that a favorites tab is to be included as one of the navigation panes in a tri-pane windowsin a tri-pane window. This property is not supported in version 1. HHWIN_PROP_CHANGE_TITLE Specifies that the title bar of the HTML Help window should reflect the title of any HTML file displayed in the HTML pane. HHWIN_PROP_TAB_ADVANCED Specifies that an advanced search tab is to be included as one of the navigation panes of a tri-pane window. The fsToolBarFlags member is used to specify which buttons to display in the toolbar. This member may be a combination of one or more of the following values:
HHWIN_BUTTON_EXPAND Expand/contract button (for the navigational pane) HHWIN_BUTTON_BACK Back button. HHWIN_BUTTON_FORWARD Forward button. HHWIN_BUTTON_STOP Stop button. HHWIN_BUTTON_REFRESH Refresh button. HHWIN_BUTTON_HOME Home button (to the HTML file defined for the window). HHWIN_BUTTON_HISTORY History button. HHWIN_BUTTON_FAVORITES Favorites button. HHWIN_BUTTON_TOC Table of Contents button. HHWIN_BUTTON_INDEX Index button. HHWIN_BUTTON_SEARCH Simple search button. HHWIN_BUTTON_HISTORY History button. HHWIN_BUTTON_FAVORITES Favorites button. HHWIN_BUTTON_JUMP1 Jump1 button. HHWIN_BUTTON_JUMP2 Jump2 button The curNavType membmermember is used to specify which navigational UI tab should be activated. This member may be one of the following values:
HHWIN_NAVTYPE_TOC Displays the Contents tab. HHWIN_NAVTYPE_INDEX Displays the Index tab. The tabpos member is used to specify where the tabs are to be placed on the navigational pane of a tri-pane window. This member may be one of the following values:
HHWIN_NAVTAB_TOP Places the tabs at the top. HHWIN_NAVTAB_LEFT Places the tabs at the left. HHWIN_NAVTAB_BOTTOM Places the tabs at the bottom. HH_POPUP structure
The HH_POPUP structure is used when displaying a text-only popup. Because of the speed in which they display, text-only popups should be used when no formatting is needed. The text to display may reside in a resource file, in a text string, or in a text file.
typedef struct tagHH_POPUP
{
int cbStruct; // sizeof this structure
HINSTANCE hinst; // instance handle for string resource
UINT idString; // string resource id, or text id if pszFile is specified in HtmlHelp call
LPCTSTR pszText; // used if idString is zero
POINT pt; // top center of popup window
COLORREF clrForeground; // use -1 for default
COLORREF clrBackground; // use -1 for default
RECT rcMargins; // amount of space between edges of window and text, -1 for each member to ignore
LPCTSTR pszFont; // facename, point size, char set, BOLD ITALIC UNDERLINE
} HH_POPUP;
Member Description cbStruct
Specifies the size of the structure. This value must always be filled in before passing the structure to the HtmlHelp API. hinst
Instance handle of the program or dll to retrieve the string resource from. Ignored if idString is zero, or a filename was passed to the HtmlHelp API. idString
Specifies either a resource id, or a thethe topic number in a text file. pszText
Specifies the text to display if idString is zero. pt
Specifies where the top center of the popup should be located. clrForeground
Specifies the RGB value to use for the foreground color. If this value is -1, the system color for window text will be used. clrBackground
Specifies the RGB value to use for the background color. If this value is -1, the system color for window background will be used. rcMargins
Specifies the margins to use on the left, top, right, and bottom sides of the popup. A -1 for any of the rectangle members will use the default. pszFont
Specifies an optional text string containing: facename[,point size[,charset[,color[, BOLD ITALIC UNDERLINE]]]]. This string specifies a font, its point size, its character set, its color, and various attributes. Options may be omitted by simply specifying the next comma. For example, to create a bold, 10-pt MS Sans Serif font, the parameter value would be: MS Sans Serif, 10, , , BOLD TRI-PANE Windows
A tri-pane window consists of three panes (child windows) consisting of a toolbar pane at the top, a navigation pane on the left, and an HTML pane that hosts SHDOCVW on the right. The navigation pane may be expanded or contracted by the user or programmatically. Expansion always enlarges the window by a fixed amount – that amount is 250 pixels by default, but may be set by the author or programmer as part of the window description.
If more then one navigational UI is specified, then a tabbed control will be used to switch between the navigational UI. By default, the tabs for this control will run vertically – but a window may be defined to have the tabs on top or the bottom.
An embedded window can take advantage of the toolbar pane without having a navigational pane by simply not including the Expand button. For example, the Help tab of the Index editor in HTML Help Workshop (displayed when editing a keyword) uses a tri-pane window without the navigation pane.
Notification Messages
If the idNotify member of the HH_WINTYPE structure is non-zero, then WM_NOTIFY messages will be sent to the last caller of the HTML Help window.
Notification lParam Description HHN_NAVCOMPLETE HHNNAVCOMPLETE* Sent when the user successfully navigates to a URL. HHN_TRACK HHNTRACK* Sent if the window has tracking properties and the user uses a toolbar button or switches navigational tabs. The message is sent before the action is taken. If the action changes to a different URL, a HHN_NAVCOMPLETE notification will be sent after this notification. HHNNAVCOMPLETE structure
typedef struct tagHHNNAVCOMPLETE {
NMHDR hdr;
PCSTR pszUrl;
} HHNNAVCOMPLETE;
Member Description hdr Standard WM_NOTIFY header pszUrl Multi-byte, zero terminated string specifying the URL that has been navigated to. HHNTRACK structure
typedef struct tagHHNTRACK
{
NMHDR hdr;
PCSTR pszCurUrl; // Multi-byte, null-terminated string
int idAction; // HHACT_ value
} HHNTRACK;
Member Description hdr Standard WM_NOTIFY header pszCurUrl Multi-byte, zero terminated string specifying the current URL before the action is taken. idAction Specifies the action the user is about to take. This is one of the HHACT_ constants described below. The idAction parameter may be one of the following values:
Value Description HHACT_EXPAND The user is about to expand the navigation pane. HHACT_CONTRACT The user is about to contract the navigation pane. HHACT_BACK The user clicked the Back button. HHACT_FORWARD The user clicked the Forward button. HHACT_STOP The user clicked the Stop button. HHACT_REFRESH The user clicked the Refresh button. HHACT_HOME The user clicked the Home button. HHACT_SYNC The user clicked the Sync button. HHACT_OPTIONS The user clicked the Options button. HHACT_PRINT The user clicked the Print button. HHACT_TAB_CONTENTS The user switched to the Contents tab. HHACT_TAB_INDEX The user switched to the Index tab. HHACT_TAB_FIND The user switched to the Find tab. HHACT_TAB_HISTORY The user switched to the History tab. HHACT_TAB_FAVORITES The user switched to the Favorites tab. Keyword Lookup
A caller may use the HtmlHelp API to lookup a keyword in a .HHK file, whether or not that file is the current keyword index or not. The .HHK file to be searched can exist on its own, or it can be in a compiled HTML file. The path to the file may be preceded with %SystemRoot% to make the path relative to the Windows directory. If the file is not found, it will be searched for in the following locations (and in the following order):
- The registry (HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\HTML Help\base filename). The filename without the path is used as the key, and the value contains the path where the file is located.
- The Windows\help folder.
- The [FILES] section of HH.INI. The keyword is the filename without the path, and the value is aan optionally quoted path optionally followed by a message to prompt the user if the file still cannot be found. For example: myfile.hhk="d:\myapp" Please insert the MyDisk CD into your CDROM drive.
If the filename portion of the HtmlHelp API call contains both a filename and a window type, then the window type will be used to determine what window to display the result in. This window type will overrrideoverride any window type specified in the .HHK file.
If the window type is not specified, the current window will be used (if there is one) unless the .HHK file specifies a window type. If no window type is specified either in the filename or the .HHK file, a default window type called "Keyword Lookup" will be created and used.
If the filename portion is not specified, but the window type is (for example, ">MyWindow") then the .HHK file associated with that window type will be searched.
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.