unit helplib;
interface
uses
Windows, Sysutils, Classes, HelpIntfs, Forms, dialogs;
type
TBumHelpViewer =
class(TInterfacedObject, ICustomHelpViewer)
private
FViewerID: Integer;
FHelpManager: IHelpManager;
public
function GetViewerName:
string;
// UnderstandsKeyword -> GetHelpStrings -> ShowHelp;
function UnderstandsKeyword(
const HelpString:
String): Integer;
function GetHelpStrings(
const HelpString:
String): TStringList;
function CanShowTableOfContents: Boolean;
procedure ShowHelp(
const HelpString:
String);
procedure ShowTableOfContents;
procedure NotifyID(
const ViewerID: Integer);
procedure SoftShutDown;
procedure ShutDown;
property HelpManager: IHelpManager
read FHelpManager
write FHelpManager;
property ViewerID: Integer
read FViewerID;
end;
TBumHelpSelector =
class(TInterfacedObject, IHelpSelector)
public
function SelectKeyword(Keywords: TStrings): Integer;
function TableOfContents(Contents: TStrings): Integer;
end;
const
HELP_VIEWER_NAME = '
Bummi Help Viewer';
implementation
uses Mainformp;
function TBumHelpViewer.CanShowTableOfContents: Boolean;
begin
Result := True
end;
function TBumHelpViewer.GetHelpStrings(
const HelpString:
String): TStringList;
begin
Result := TStringList.Create;
Result.Add(HelpString);
end;
function TBumHelpViewer.GetViewerName:
string;
begin
Result := HELP_VIEWER_NAME;
end;
procedure TBumHelpViewer.NotifyID(
const ViewerID: Integer);
begin
FViewerID := ViewerID;
end;
procedure TBumHelpViewer.ShowHelp(
const HelpString:
String);
begin
Mainform.ShowHelp(HelpString);
end;
procedure TBumHelpViewer.ShowTableOfContents;
begin
end;
procedure TBumHelpViewer.ShutDown;
begin
end;
procedure TBumHelpViewer.SoftShutDown;
begin
end;
function TBumHelpViewer.UnderstandsKeyword(
const HelpString:
String): Integer;
begin
Result := 1;
end;
function TBumHelpSelector.SelectKeyword(Keywords: TStrings): Integer;
begin
Result := 1
end;
function TBumHelpSelector.TableOfContents(Contents: TStrings): Integer;
begin
Result := Contents.IndexOf(HELP_VIEWER_NAME);
end;
var
HelpViewer: TBumHelpViewer;
initialization
HelpViewer := TBumHelpViewer.Create;
inttostr(HelpIntfs.RegisterViewer(HelpViewer, HelpViewer.FHelpManager));
(HelpViewer.FHelpManager
as IHelpSystem).AssignHelpSelector(TBumHelpSelector.Create);
end.