Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-09

problem opening html help pages with spaces in path

15 messages · 9 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrea Mauri
I added to my application:
     helpBrowser: THTMLBrowserHelpViewer;
     helpDB: THTMLHelpDatabase;
Then I set the properties:
   helpDB.BaseURL:= 'file://help/';
   helpDB.KeywordPrefix:= 'HELP/';
   HelpKeyword:= 'HELP/index.html';

Actually it works except when the html help pages are on a path including spaces.
For example if my application is in: d:\myapp\
and the help is in: d:\myapp\help\index.html
it works correctly

But if in the path there are spaces like: d:\my app\help\index.html The html page is not shown correctly, for example firefox open two tabs: file:///D:/my
and a second tab
app\help\index.html

The same happens calling:
   ShowHelpOrErrorForKeyword('','HELP/page.htm');

what I have to do?
regards,
andrae

Bart
to Andrea Mauri

Replace spaces with %20 ?

Bart

Andrea Mauri wrote 34 lines
I added to my application: helpBrowser: THTMLBrowserHelpViewer; helpDB: THTMLHelpDatabase; Then I set the properties: helpDB.BaseURL:= 'file://help/'; helpDB.KeywordPrefix:= 'HELP/'; HelpKeyword:= 'HELP/index.html'; Actually it works except when the html help pages are on a path including spaces. For example if my application is in: d:\myapp\ and the help is in: d:\myapp\help\index.html it works correctly But if in the path there are spaces like: d:\my app\help\index.html The html page is not shown correctly, for example firefox open two tabs: file:///D:/my and a second tab app\help\index.html The same happens calling: ShowHelpOrErrorForKeyword('','HELP/page.htm'); what I have to do? regards, andrae -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Mattias Gaertner
to Bart
Replace spaces with %20 ?

Is there already a function for this that can be used in the LCL?

Mattias

Show quoted text 44 lines
Bart On 9/14/10, Andrea Mauri wrote: > I added to my application: > helpBrowser: THTMLBrowserHelpViewer; > helpDB: THTMLHelpDatabase; > > Then I set the properties: > helpDB.BaseURL:= 'file://help/'; > helpDB.KeywordPrefix:= 'HELP/'; > HelpKeyword:= 'HELP/index.html'; > > Actually it works except when the html help pages are on a path > including spaces. > For example if my application is in: d:\myapp\ > and the help is in: d:\myapp\help\index.html > it works correctly > > But if in the path there are spaces like: d:\my app\help\index.html > The html page is not shown correctly, for example firefox open two tabs: > file:///D:/my > and a second tab > app\help\index.html > > The same happens calling: > ShowHelpOrErrorForKeyword('','HELP/page.htm'); > > what I have to do? > regards, > andrae > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Mattias Gaertner
to Alberto Narduzzi
Show quoted text 5 lines
> Is there already a function for this that can be used in the LCL? I may guess... S := StringReplace(S, ' ', '%20', [rfReplaceAll]);

I meant for all special characters.

Mattias

Žilvinas Ledas
to Mattias Gaertner
Mattias Gaertner wrote 10 lines
On Tue, 14 Sep 2010 19:28:19 +0300 Alberto Narduzzi wrote: >> Is there already a function for this that can be used in the LCL? > I may guess... > > S := StringReplace(S, ' ', '%20', [rfReplaceAll]); I meant for all special characters. Mattias

LNet has function HTTPEncode() (in lHTTPUtil unit), which should do what is required here.

Regards
?ilvinas Ledas

ABorka
to Mattias Gaertner: On Tue, 14 Sep 2010 19:28:19 +0300 I meant for all special characters. Mattias
Mattias Gaertner wrote 12 lines
On Tue, 14 Sep 2010 19:28:19 +0300 Alberto Narduzzi wrote: >> Is there already a function for this that can be used in the LCL? > > I may guess... > > S := StringReplace(S, ' ', '%20', [rfReplaceAll]); I meant for all special characters. Mattias

You can use the HTTPEncode function from
.../packages/fcl-web/src/base/httpdefs.pp

and the HTTPDecode to convert things back if needed.

AB

Leonardo M. Ramé
to ABorka

Hi, I'm trying to print images from a CGI app using the TPrinter class from printers unit without success.

Apparently this is related to Printer.canvas, that's part of Graphics unit, who relies on calls to X11 or Windows api, instead of using TFPCanvas.

Does anyone knows a way to print images without using Graphics.Canvas?

Andrea Mauri
to ABorka: You can use the HTTPEncode function from .../packages/fcl-web/src/base/httpdefs.pp and…

Il 14/09/2010 18.52, ABorka ha scritto:

You can use the HTTPEncode function from .../packages/fcl-web/src/base/httpdefs.pp and the HTTPDecode to convert things back if needed.

so, what I have to do? I have to use HTTPEncode? Where? Using THTMLBrowserHelpViewer I don't have direct access to the url, I just set the BaseURL (e.g. 'file://help/') and KeywordPrefix (e.g. 'HELP/'). andrea

Mattias Gaertner
to Andrea Mauri
Show quoted text 10 lines
Il 14/09/2010 18.52, ABorka ha scritto: > You can use the HTTPEncode function from > .../packages/fcl-web/src/base/httpdefs.pp > > and the HTTPDecode to convert things back if needed. so, what I have to do? I have to use HTTPEncode? Where? Using THTMLBrowserHelpViewer I don't have direct access to the url, I just set the BaseURL (e.g. 'file://help/') and KeywordPrefix (e.g. 'HELP/'). andrea

I fixed FindDefaultBrowser to add "" around the parameter. Please test with svn revision 27397.

Mattias

Andrea Mauri
to Mattias Gaertner

Il 17/09/2010 17.23, Mattias Gaertner ha scritto:

I fixed FindDefaultBrowser to add "" around the parameter. Please test with svn revision 27397.

Tested. It does not work. I am actually using it both on win and linux. I tested it only on win and I got the same problem as before. Actually on Win I do not use FindDefaultBrowser because it does not work on my machine because it uses

   Find('rundll32', ABrowser);
function Find(const ShortFilename: String; out ABrowser: String):
Boolean; inline;
   begin
     ABrowser := SearchFileInPath(ShortFilename + GetExeExt, '',
                       GetEnvironmentVariableUTF8('PATH'), PathSeparator,
                       [sffDontSearchInBasePath]);
     Result := ABrowser  '';
   end;

That looks for rundll32 on PATH but in my PATH there is not System32 directory where rundll32 is located.

So in order to find the default browser on Win I use this function:

function GetDefaultBrowser: string;
var
   Brow: string;
   {$IFDEF MSWINDOWS}
   Reg: TRegistry;
   {$ENDIF}
begin
   Brow:= '';
   {$IFDEF MSWINDOWS}
   Reg:= TRegistry.Create;
   with Reg do
   begin
     RootKey:= HKEY_CURRENT_USER;
     if OpenKeyReadOnly('SOFTWARE\Clients\StartMenuInternet') then
     begin
       Brow:=ReadString('');
       CloseKey;
       RootKey:=HKEY_LOCAL_MACHINE;
       Brow:=
Format('SOFTWARE\Clients\StartMenuInternet\%s\shell\open\command', [brow]);
       if OpenKeyReadOnly(brow) then
       begin
         Brow:=ReadString('');
         CloseKey;
       end;
     end;
   end;
   Reg.Free;
   Brow:= StringReplace(brow, '"', '', [rfReplaceAll]);
   {$ENDIF}
   Result:= Brow;
end;

If it does not work the user can change manually the browserpath property.

Mattias Gaertner
to Andrea Mauri
Show quoted text 6 lines
Il 17/09/2010 17.23, Mattias Gaertner ha scritto: > I fixed FindDefaultBrowser to add "" around the parameter. > Please test with svn revision 27397. Tested. It does not work. I am actually using it both on win and linux. I tested it only on win and I got the same problem as before.

Sorry, I thought this was on Linux. I only changed the Linux/Mac part.

For the windows devels: Should the below be added as fallback method when no browser was found in PATH?

Show quoted text 53 lines
Actually on Win I do not use FindDefaultBrowser because it does not work on my machine because it uses Find('rundll32', ABrowser); function Find(const ShortFilename: String; out ABrowser: String): Boolean; inline; begin ABrowser := SearchFileInPath(ShortFilename + GetExeExt, '', GetEnvironmentVariableUTF8('PATH'), PathSeparator, [sffDontSearchInBasePath]); Result := ABrowser ''; end; That looks for rundll32 on PATH but in my PATH there is not System32 directory where rundll32 is located. So in order to find the default browser on Win I use this function: function GetDefaultBrowser: string; var Brow: string; {$IFDEF MSWINDOWS} Reg: TRegistry; {$ENDIF} begin Brow:= ''; {$IFDEF MSWINDOWS} Reg:= TRegistry.Create; with Reg do begin RootKey:= HKEY_CURRENT_USER; if OpenKeyReadOnly('SOFTWARE\Clients\StartMenuInternet') then begin Brow:=ReadString(''); CloseKey; RootKey:=HKEY_LOCAL_MACHINE; Brow:= Format('SOFTWARE\Clients\StartMenuInternet\%s\shell\open\command', [brow]); if OpenKeyReadOnly(brow) then begin Brow:=ReadString(''); CloseKey; end; end; end; Reg.Free; Brow:= StringReplace(brow, '"', '', [rfReplaceAll]); {$ENDIF} Result:= Brow; end; If it does not work the user can change manually the browserpath property.

Mattias

zeljko
to Mattias Gaertner
Mattias Gaertner wrote 14 lines
On Fri, 17 Sep 2010 18:03:00 +0200 Andrea Mauri wrote: > Il 17/09/2010 17.23, Mattias Gaertner ha scritto: > > I fixed FindDefaultBrowser to add "" around the parameter. > > Please test with svn revision 27397. > > Tested. It does not work. I am actually using it both on win and linux. > I tested it only on win and I got the same problem as before. Sorry, I thought this was on Linux. I only changed the Linux/Mac part. For the windows devels: Should the below be added as fallback method when no browser was found in PATH?

I'm not windows devel ;) but that fallback looks good.

Zaher Dirkey
to Leonardo M. Ramé: Hi, I'm trying to print images from a CGI app using the TPrinter class from printers unit…

Did you try "nogui" Wedgetset?

Leonardo M. Ram? wrote 19 lines
Hi, I'm trying to print images from a CGI app using the TPrinter class from printers unit without success. Apparently this is related to Printer.canvas, that's part of Graphics unit, who relies on calls to X11 or Windows api, instead of using TFPCanvas. Does anyone knows a way to print images without using Graphics.Canvas? -- Leonardo M. Ram? http://leonardorame.blogspot.com -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Zaher Dirkey -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100920/23a0262a/attachment.html>
Andrea Mauri
to Mattias Gaertner: On Fri, 17 Sep 2010 18:03:00 +0200 Sorry, I thought this was on Linux. I only changed the…

Il 17/09/2010 18.11, Mattias Gaertner ha scritto:

Sorry, I thought this was on Linux. I only changed the Linux/Mac part.

In order to avoid problems related to spaces in help path I added a line in LazHelpHTML unit, function

function THTMLHelpDatabase.ShowURL(const URL, Title: string; var ErrMsg:
string
   ): TShowHelpResult;
I added after this line:
   FullURL:= CombineURL(URLType,URLPath,URLParams);

this:

   {$IFDEF MSWINDOWS}
   FullURL:= '"' + FullURL + '"'
   {$ENDIF}

It works but I am not sure it is the best way to do this. andrea