The HTML Help function

Enables you to send commands to the HTML Help engine.

Declaration:

function HtmlHelp(hwndCaller: HWND; pszFile: PChar; uCommand: UINT; dwData: DWORD): HWND; stdcall;

Description:
The HTML Help API provides only one function named HtmlHelp. However, like many API functions it is very powerfull and provides you with a lot of different options. This function enables you to specify which topic you want to display, in which help window you want it displayed and how the topic should be accesses - via context ID, HTML Help URL or a keyword link (KLink) lookup.

Parameter Description
hwndCaller Specifies the handle of an application window or 0. The help window is owned by the specified window and focus will return to it when the help window is closed. Furthermore any notification messages are sent to this window. If you specify 0 then the desktop is the owner. You will not be able to get notification messages and the Operating System determines which window will get the focus when the help window is closed, not necessarily any of your application windows.
pszFile Specified the topic to display and optionally, the window in which it should appear. See HTML Help URLs for information on the syntax for this parameter. For commands that do not require a topic this parameter may be set to nil.
uCommand Specifies the command to execute. See Commands for the possible values of this parameter.
dwData Specifies additional data which depends on the uCommand value. This wil either be the address of one of the structures described in the structures section or 0 if the command does not require additional data.

Return value:
Depending on the uCommand parameter and the result the return value of the HtmlHelp function will be either the handle of the window that was created/affected by the call, or 0. In cases where 0 means failure (which is not always the case) you can get additional information about the cause of failure by using the Messages command on the View menu of the HTML Help Workshop or by using the HH_GET_LAST_ERROR command. However, both these methods do not always return usefull information, if any.

Example:
The following code snippet demonstrates how to use the HtmlHelp function to display a topic named "HtmlHelp.htm" from the "JediHtmlHelp.chm" helpfile in a window named "Main" (this happens to be the topic your looking at right now). The desktop is specified as the owner of the window.

procedure TForm1.Button1Click(Sender: TObject);
const
  URL =
'JediHtmlHelp.chm::/HTML\Functions\HtmlHelp.htm>Main';
begin

  if HtmlHelp(GetDesktopWindow, PChar(URL), HH_DISPLAY_TOPIC,
0) = 0   then
    ShowMessage(
'Unable to display topic');
end;

Notes:
If HTML Help cannot find the specified help file (because it is not in either the Windows\Help or current folder) then the user will be prompted to located the helpfile. After it is located HTML Help remembers the location, and other settings specific for this helpfile, in a file called hh.dat located in the Windows folder. Nevertheless you will usually want to specify the full path to the helpfile so the user won't be confronted with the locate file dialog.

See also:
Commands
Structures
Notifications