Files
lazarus-ccr/applications/lazstats/source/forms/misc/contexthelpunit.pas

75 lines
1.4 KiB
ObjectPascal
Raw Normal View History

unit ContextHelpUnit;
{$mode objfpc}
{$H+}
interface
uses
IniFiles, Classes, SysUtils, Forms, Controls, Graphics,
Dialogs, ExtCtrls, StdCtrls;
type
{ TContextHelpForm }
TContextHelpForm = class(TForm)
Button1: TButton;
HelpMemo: TMemo;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
private
public
procedure HelpMessage(ATag: integer);
end;
var
ContextHelpForm: TContextHelpForm;
implementation
{$R *.lfm}
// Read string with index ATag
function ReadHlpFileTag(var ATag: Integer): string;
var
lIniFile: TIniFile;
lFileName, lLang: string;
begin
lFilename := ChangeFileExt(ParamStr(0), '.hlp');
if not FileExists(lFilename) then begin
Result := 'No context help: unable to find helo file "' + lFilename + '"';
exit;
end;
lIniFile := TIniFile.Create(lFilename);
try
lLang := lIniFile.ReadString('LANGUAGE', 'DEFAULT', '');
Result := lIniFile.ReadString(lLang, IntToStr(ATag), Result);
if Result <> '' then
Result := StringReplace(Result, '\n', LineEnding, [rfIgnoreCase, rfReplaceAll])
else
Result := 'No context help found for ' + IntToStr(ATag);
finally
lIniFile.Free;
end;
end;
procedure TContextHelpForm.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TContextHelpForm.HelpMessage(ATag: integer);
begin
HelpMemo.Lines.Text := ReadHlpFileTag(ATag);
Show;
end;
end.