Recent

Author Topic: How to make a simple Link ?  (Read 10781 times)

Nisbo

  • New Member
  • *
  • Posts: 19
How to make a simple Link ?
« 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

Nisbo

  • New Member
  • *
  • Posts: 19
How to make a simple Link ?
« Reply #1 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;

Nisbo

  • New Member
  • *
  • Posts: 19
How to make a simple Link ?
« Reply #2 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 ?

Anonymous

  • Guest
How to make a simple Link ?
« Reply #3 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

Nisbo

  • New Member
  • *
  • Posts: 19
How to make a simple Link ?
« Reply #4 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;

Lightning

  • Sr. Member
  • ****
  • Posts: 422
How to make a simple Link ?
« Reply #5 on: March 15, 2005, 08:30:15 am »
Also don't use Application.Handle, that handle is invalid, bug ...
The future must be... Fast and OpenSource so...
Think Open and Lightning Fast!

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
How to make a simple Link ?
« Reply #6 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?)

antonio

  • Hero Member
  • *****
  • Posts: 605
How to make a simple Link ?
« Reply #7 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}

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
How to make a simple Link ?
« Reply #8 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)

:)

antonio

  • Hero Member
  • *****
  • Posts: 605
How to make a simple Link ?
« Reply #9 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.

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
How to make a simple Link ?
« Reply #10 on: June 17, 2007, 05:07:20 am »
Thanks :)

dje

  • Full Member
  • ***
  • Posts: 134
Re: How to make a simple Link ?
« Reply #11 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

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: How to make a simple Link ?
« Reply #12 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018