Lazarus

Using the Lazarus IDE => Editor => Topic started by: Nisbo on March 08, 2005, 04:15:52 pm

Title: How to make a simple Link ?
Post by: Nisbo on March 08, 2005, 04:15:52 pm
first, sorry for my bad english, but i am from germany

How to make a simple Link ?

this is my questing, i searched in google and I found for delphi:

ShellExecute(handle,nil,'http://www.google.de',nil,SW_SHOW)
shellexecute(0, 'open', 'http://www.google.de', nil, nil, sw_show);

but it doesnt work in lazarus

maybe there is an other funktion to make a simple html-link like a link to a supportpage
Title: How to make a simple Link ?
Post by: Nisbo on March 10, 2005, 10:54:32 am
OK no answer is also an answer  :roll:

the solution is

insert inso uses: ShellAPI

and you can use

procedure TForm1.MenuItem3Click(Sender: TObject);
var sw_show: longint;
begin
     Shellexecute(handle,'open',PChar('http://www.google.de'),'','',sw_show);
end;
Title: How to make a simple Link ?
Post by: Nisbo on March 10, 2005, 03:03:12 pm
OK next question

I try to open notepad (W2K)

Shellexecute(Application.Handle,'open',PChar('C:\WINNT\NOTEPAD.EXE'),nil,nil,sw_show);

but it doesnt work, whats wrong ?
Title: How to make a simple Link ?
Post by: Anonymous on March 10, 2005, 06:18:34 pm
Use ExecuteProcess instead

Try like this:
ExecuteProcess('C:\WINNT\NOTEPAD.EXE','');
second arguments are arguments passed to Notepad
Title: How to make a simple Link ?
Post by: Nisbo on March 10, 2005, 06:28:41 pm
ok my mistake was that i forgot to insert Windows in units
now it works

procedure TForm1.MenuItem5Click(Sender: TObject);
begin
     Shellexecute(handle,'open',PChar('http://www.google.de'),'','',sw_show);
end;
Title: How to make a simple Link ?
Post by: Lightning on March 15, 2005, 08:30:15 am
Also don't use Application.Handle, that handle is invalid, bug ...
Title: How to make a simple Link ?
Post by: Hansaplast on June 17, 2007, 02:17:55 am
Is there a universal way on to how to make a click able link suitable for all platforms?
Using Windows specific units comes with complications for Linux etc?? (or not?)
Title: How to make a simple Link ?
Post by: antonio on June 17, 2007, 04:18:30 am
Quote from: "Hansaplast"
Using Windows specific units comes with complications for Linux


Not necessarily.

Anyway, you can put IFDEF directive in your code.

Code: [Select]

{$IFDEF WINDOWS}
// Windows specific part
{$ENDIF}
Title: How to make a simple Link ?
Post by: Hansaplast on June 17, 2007, 04:21:49 am
IFDEF is a good approach,... if I would know;

a) which platform identifications I'd use in the IFDEF (win32, linux,... but not sure about Mac OSX and such?)
b) what to call for on the other platforms (which I do not - yet)

:)
Title: How to make a simple Link ?
Post by: antonio on June 17, 2007, 04:23:26 am
I edited my post after you posted yours. See it again.

For a complete example, see eg. SynEdit source.
Title: How to make a simple Link ?
Post by: Hansaplast on June 17, 2007, 05:07:20 am
Thanks :)
Title: Re: How to make a simple Link ?
Post by: dje on June 30, 2022, 07:30:18 am
Is there a universal way on to how to make a click able link suitable for all platforms?
Using Windows specific units comes with complications for Linux etc?? (or not?)

I use OpenURL and OpenDocument from the unit LCLIntf. The only problem I found on the Raspberry Pi, is when xdg-open is not setup with a valid default browser.

The following will show your current default browser
Code: [Select]
xdg-settings get default-web-browser
I believe I had to use something like this to make it work with firefox. (I guess it depends on the linux distro)
Code: [Select]
xdg-settings set default-web-browser firefox-esr.desktop
Title: Re: How to make a simple Link ?
Post by: MarkMLl on June 30, 2022, 09:17:51 am
You're commenting to a thread that's 15 years old, and most if not all of the participants have moved on.

I use OpenURL and OpenDocument from the unit LCLIntf. The only problem I found on the Raspberry Pi, is when xdg-open is not setup with a valid default browser.

That is of course an interesting point, and you deserve a point for investigating xdg-open. However you've got a definite distro bug there, and you need to make sure it's reported as a bug to the RPi maintainers.

MarkMLl
TinyPortal © 2005-2018