chmhelp: demo: find lhelp under OS X

git-svn-id: trunk@37968 -
This commit is contained in:
mattias 2012-07-19 08:10:46 +00:00
parent d0c7f0ea98
commit 3df0a944a5
2 changed files with 37 additions and 12 deletions

View File

@ -1,16 +1,18 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<Version Value="7"/>
<General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<SessionStorage Value="InIDEConfig"/>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
</General>
<BuildModes Count="1">
<Item1 Name="default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
@ -48,12 +50,17 @@
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<OtherUnitFiles Value="..\lhelp\"/>
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
<OtherUnitFiles Value="..\lhelp"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Options>
<Win32>

View File

@ -6,8 +6,10 @@ interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, LHelpControl,
Buttons, StdCtrls;
Buttons, StdCtrls, FileUtil;
const
IPCFile = 'letstestagain';
type
{ TForm1 }
@ -20,10 +22,9 @@ type
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
function GetLHelpFilename: string;
end;
var
Form1: TForm1;
@ -41,7 +42,6 @@ begin
srInvalidFile:Result := 'InvalidFileName';
srInvalidURL:Result := 'InvalidURL';
srInvalidContext:Result := 'InvalidContext';
end;
end;
@ -49,15 +49,25 @@ procedure TForm1.Button1Click(Sender: TObject);
var
Res: TLHelpResponse;
begin
OpenDialog1.InitialDir:=GetCurrentDirUTF8;
if not OpenDialog1.Execute then exit;
if Help.ServerRunning = false then
Help.StartHelpServer('letstestagain', '../lhelp/lhelp');
Help.StartHelpServer(IPCFile, GetLHelpFilename);
Res :=Help.OpenFile(OpenDialog1.FileName);
Label1.Caption := ResponseToString(Res);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
LHelp: String;
begin
{$IFDEF Unix}
DeleteFile('/tmp/'+IPCFile);
{$ENDIF}
LHelp:=GetLHelpFilename;
if not FileExistsUTF8(LHelp) then
MessageDlg('Missing lhelp','Can not find the lhelp application "'+LHelp+'"',
mtError,[mbOk],0);
Help := TLHelpConnection.Create;
Help.ProcessWhileWaiting := @Application.ProcessMessages;
end;
@ -67,6 +77,14 @@ begin
Help.Free;
end;
function TForm1.GetLHelpFilename: string;
begin
Result:='../lhelp/lhelp';
{$IFDEF darwin}
Result:=Result+'.app/Contents/MacOS/'+ExtractFilename(Result);
{$ENDIF}
end;
initialization
{$I unit1.lrs}