You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7828 8e941d3f-bd1b-0410-a28a-d453659cc2b4
75 lines
1.4 KiB
ObjectPascal
75 lines
1.4 KiB
ObjectPascal
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.
|
|
|