⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 列表8.2.txt

📁 klinux书籍的配套光盘。可以学习学习。
💻 TXT
字号:
【列表8.2】TsimpleHelpViewe类的实现代码。
{TSimpleHelpViewer}
constructor TSimpleHelpViewer. Create;
begin
   inherited Create;
   FHelpStrings := TStringList. Create;
end;
destructor TSimpleHelpViewer.Destroy;
begin
   FHelpStrings,Free;
   inherited Destroy;
end;
{
   The unit finalization code calls InternalShutdown to shutdown the Viewer
   and notify the HelpManager that the Viewer is gone.
 }
procedure TSimpleHelpViewer. InternalShutdown;
 begin
    if Assigned (FHelpManager) then
       FHelpManager. Release (FViewerID);
    Shutdown;
 end;
    The HelpManager calls GetViewerName to provide a unique string identifier
    that uers nan use to select amonq multiple help systems.
function  TSimpleHelpViewer. GetViewerName : String;
begin
   Result := STR_VIEWER_NAME;
end;
{
   The HelpManager calls UnderstandsKeywords to ask if the Viewer supports
   a particular keyword. The Viewer responds with the number of topics
   that match the keyword. A return value of 0 indicates that the
   viewer doesn't support that keyword.
}
function  TSimpleHelpViewer. UnderstandsKeyword
   (const HelpString: String): Integer;
begin
   // SimpleHelpViewer always understands keywords
   FHelpStrings.Clear;
   FHelpStrings.Add ('Main');
   Result := FHelpStrings.Count;
end;
 {
When more than one Viewer supports help for a particular keyword, and
   the HelpManager needs to display a UI element to allow the user to select
   a keyword, it will call GetHelpStrings to get the string list that the
   Viewer built during UnderstandsKeywords.
   The HelpManager guarantees that it will only call this function
   after calling UnderstandsKeywords, so it's OK to build the list during
   that function and return it here,
}
function  TSimpleHelpViewer. GetHelpStrings
    (const HelpString: String): TStringList;
begin
    Result := FHelpStrings;
end;
 {
   The HelpManager calls this function to ask if the Viewer can display
    a table of contents, If the viewer can display the TOC, it should
    return True.
 }

 function  TSimpleHelpViewer. CanShowTableOfContents : Boolean;
 begin
    { No TOC in this Viewer }
    Result := false;
 end;
{
  The HelpManager calls this procedure when it wants the Viewer to
  display the table of contents. The HelpManager should only call
  this function if CanShowTableOfContents returns True.
}
procedure TSimpleHelpViewer.ShowTableOfContents;
begin
   { Should never get here, but raise just in case... }
   raise EHelpSystemException.Create ('Unable to show table of contents');
end;
{
   The HelpManager calls this procedure when it wants the Viewer to
   display help for a particular topic.
}

procedure TSimpleHelpViewer. ShowHelp(const HelpString: String);
begin
   ShowMessage (Format ('Keyword "%s" help text.', [HelpString]));         
end;
{
   The HelpManager calls NotifyID after successful registration to provide
   the viewer with a unique value that identifies the viewer in communications
   with the HelpManager.
}
procedure TSimpleHelpViewer. NotifyID(const ViewerID: Integer);
begin
    FViewerID := ViewerID;
end;
 {
    The HelpManager calls SoftShutDown to shut down all visible portions
    of the Viewer without actually shutting down the Viewer,
 }

 procedure TSimpleHelpViewer. SoftShutDown;
 begin
    // nothing to do
 end;

 {
    The HelpManager calls ShutDown to shut down the Viewer.
    Since the HelpManager ordered the Viewer to shut down, we don't need
    to notify it.
 }
 procedure TSimpleHelpViewer. ShutDown;
begin
   if Assigned(FHelpManager) then FHelpManager := nil;
end;

initialization
   {
      Create and initialize the Viewer,
      and register it with the HelpManager.
   }
   if not Assigned(HelpViewer) then
   begin
      He!pViewer := TSimpleHelpViewer. Create;
      HelpIntfs. RegisterViewer(HelpViewer, HelpViewer. FHelpManager);
   end;

finalization
   { Shutdown and free the Viewer. }
   if Assigned(HelpViewer) then
   begin
      HelpViewer. InternalShutDown;
      HelpViewer. Free;
   end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -