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

View File

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