RAD Studio [Emaix45] How to Show your Help for any element (by "constant string" or ContextID=Integer) in your project using Help Files HLP or CHM

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,438
Credits
573
Easy way to Show your Help for any element (by "constant string" or ContextID=Integer) in your project using Help Files HLP or CHM (default by RAD Studio)
by Emailx45

You need, first know:
  • if "the External Viewer Help" is ok in your MSWindows! Else, nothing will be showed!
  • Of course, if you are using another way, then, you need to know "how it works".
  • Read more info in Help System to know "how create yourself help file"

[SHOWTOGROUPS=4,20,22]
1597705969024.png

Код:
unit uFormMain;

interface

uses
  Winapi.Windows,
  Winapi.Messages,
  System.SysUtils,
  System.Variants,
  System.Classes,
  Vcl.Graphics,
  Vcl.Controls,
  Vcl.Forms,
  Vcl.Dialogs,
  Vcl.ComCtrls,
  Vcl.ToolWin,
  Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    btnCallMy_HelpFile_With_ContextID_PreDefined_In_HLPorCHM: TButton;
    procedure btnCallMy_HelpFile_With_ContextID_PreDefined_In_HLPorCHMClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  System.HelpIntfs,   {interfaces to manipulate the External Viewer Help files}
  Vcl.HtmlHelpViewer; { necessary to access "private" objects }

procedure TForm1.btnCallMy_HelpFile_With_ContextID_PreDefined_In_HLPorCHMClick(Sender: TObject);
var
  lHlpSys     : IHelpSystem;
  lMyContextID: THelpContext; // = -MaxInt..MaxInt;
begin
  (*
    //
    // It's necessary define what help file will be used!
    // Application.HelpFile := 'C:\EMB\RADStudioRIO\200\Help\Doc\vcl.chm'; // defining the Help File to use!
    //
    // if Application.HelpContext(1) then;
    //
    // if Application.HelpKeyword('THelpContext') then;
    //
    // if Application.HelpShowTableOfContents then;
    //
    // if Application.HelpCommand(HH_ALINK_LOOKUP, 1) then; // search on MSDN for "HTMLHelp"
  *)
  //
  //
  if System.HelpIntfs.GetHelpSystem(lHlpSys) then // same that: if not(Application.HelpSystem = nil) then;
  begin
    // ShowHelp(const HelpKeyword, HelpFileName: string);
    // ShowContextHelp(const ContextID: THelpContext; const HelpFileName: string);
    // ShowTopicHelp(const Topic, HelpFileName: string);
    //
    // lHlpSys.ShowHelp('TForm', 'C:\EMB\RADStudioRIO\200\Help\Doc\vcl.chm');
    //
    // lHlpSys.ShowContextHelp(1, 'C:\EMB\RADStudioRIO\200\Help\Doc\vcl.chm');
    //
    // Note: We recommend that you use the Vcl.Forms.TApplication.HelpShowTableOfContents method for opening the Table of Contents.
    // lHlpSys.ShowTableOfContents;
    //
    //
    // lHlpSys.ShowTopicHelp('Vcl.Printers', 'C:\EMB\RADStudioRIO\200\Help\Doc\vcl.chm');
  end else begin
    ShowMessage('System.HelpIntfs.GetHelpSystem(lHlpSys) = false');
  end;

end;

end.
[/SHOWTOGROUPS]