OnShowHelp

 

OnShowHelp is called when F1-key is pressed.

function TEmbeddedWB.ShowHelp(hwnd: THandle; pszHelpFile: POLESTR; uCommand: integer; dwData: longint; ptMouse: TPoint; var pDispatchObjectHit: IDispatch): HRESULT;

Parameters

hwnd
Handle to the owner window.
pszHelpFile
Help file name.
uCommand
Winhelp-type of Help. 
dwData
Additional data for Winhelp
ptMouse
Mouse position in screen coordinates.
pDispatchObjectHit
Idispatch of the object at the screen coordinates.

Result=S_OK means host displayed help, and IE4/MSHTML will not display its help.

Result=S_FALSE means host did not display Help. IE4/MSHTML will display its Help.

In the following sample a messagebox with the message 'No help available' pops up when F1 is pressed and EmbeddedWb has focus.

function TForm1.EmbeddedWB1ShowHelp(hwnd: Cardinal; pszHelpFile: PWideChar; uCommand, dwData: Integer; ptMouse: TPoint; var pDispatchObjectHit: IDispatch): HRESULT;
begin
   Showmessage('No help available.');
   Result := S_OK;
end;

To make the function more useful a Helpfile-property is added to EmbeddedWb. If EmbeddedWb.Helpfile is assigned the file will be shown when the user hits F1.

EmbeddedWb.OnShowHelp looks like this:

 

function HtmlHelp(hwndCaller: HWND; pszFile: PChar; uCommand: Integer; dwData: DWORD): HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpA';

function TEmbeddedWB.ShowHelp(hwnd: THandle; pszHelpFile: POLESTR; uCommand: integer; dwData: longint; ptMouse: TPoint; var pDispatchObjectHit: IDispatch): HRESULT;
begin
if Assigned(FOnShowHelp) then
Result := FOnShowHelp(hwnd, pszHelpFile, uCommand,    dwData, ptMouse, pDispatchObjectHit) else
if FHelpFile <> '' then HtmlHelp(hwnd, Pchar(FHelpFile), ucommand, dwData) else
Result := S_FALSE;
end;


Notice that the focus need to be on the document in the Webbrowser-component for ShowHelp to work. Webbrowser.setfocus don't help. In EmbeddedWB a procedure called SetFocusToDoc is added to do this job. In the following sample the access to the helpfile is an important part of the application so SetFocusToDoc is added to OnDocumentComplete. 


procedure TForm1.FormCreate(Sender: TObject);
begin
EmbeddedWb1.Helpfile:='C:\Demo\Helppage.chm';
end;

procedure TForm1.EmbeddedWB1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);
begin
EmbeddedWb1.SetFocusToDoc;
end;

 

Hint:

You can download a free Delphi-translation of HTMLHELP.H by Eric Grange on Eric's Delphi Page

See Also:

Introducing HTML help

Displaying help by using HTMLHELP API