Recent

Author Topic: How to create a Hyperlink  (Read 14724 times)

Fred vS

  • Hero Member
  • *****
  • Posts: 2727
    • StrumPract is the musicians best friend
How to create a Hyperlink
« on: November 02, 2009, 07:25:43 pm »
Hello.

How can i create a Hyperlink with lazarus.

I meen: if i click on a Tlabel, it gonna open the default Web-browser and load the hyperlink (label.caption) ?
Thanks.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 2727
    • StrumPract is the musicians best friend
Re: How to create a Hyperlink
« Reply #1 on: November 02, 2009, 07:32:27 pm »
I have founded a topic:
http://forum.lazarus.freepascal.org/index.php/topic,2313.0.html

But they said

Code: [Select]
Shellexecute(handle, 'open', pchar('http://www.link here.com'), nil,nil, sw_show);
and at top of the file; uses:
Shellapi

Hum, shellapi exists in Delphi but what about Lazarus ?  :(

Thanks
« Last Edit: November 02, 2009, 07:43:37 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

cdbc

  • Sr. Member
  • ****
  • Posts: 384
    • http://www.cdbc.dk
Re: How to create a Hyperlink
« Reply #2 on: November 03, 2009, 02:51:17 am »
Hello.

Shellexecute(); is windows specific.
Another approach would be to use TProcess and webbrowser yourself...

Regards Benny
If it ain't broke, don't fix it ;)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8436
  • Programming + Glam Metal + Tae Kwon Do = Me

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: How to create a Hyperlink
« Reply #4 on: November 03, 2009, 05:26:15 am »
Why not just use TOvcURL and let it do all the work for you:

http://web.fastermac.net/~MacPgmr/OrphPort/OrphStatus.html

Thanks.

-Phil

Fred vS

  • Hero Member
  • *****
  • Posts: 2727
    • StrumPract is the musicians best friend
Re: How to create a Hyperlink
« Reply #5 on: November 04, 2009, 05:05:31 pm »
Thanks folks, it is just what i need ;D

But, Leledumbo, how can i install browserdetection in Lazarus ?  :(
« Last Edit: November 04, 2009, 05:24:05 pm by fredvs »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Bart

  • Hero Member
  • *****
  • Posts: 4747
    • Bart en Mariska's Webstek
Re: How to create a Hyperlink
« Reply #6 on: November 05, 2009, 01:08:54 pm »
But, Leledumbo, how can i install browserdetection in Lazarus ?  :(

Unpack the sources.

Then include BrowserDetection in the uses clause of your program.

In Menu->Project->Compiler options point Lazarus to where the sources and includes are:

Example in my case:
/home/bart/LazarusProjecten/MijnLib/
and
/home/bart/LazarusProjecten/MijnLib/include/;/home/bart/LazarusProjecten/MijnLib/include/linux/

BrowserDetection has only been tested (by me, the author) on win32 and linux i386 platform.
It is based upon xdg-utils, and on linux it function best when that util is installed (but it can do without)
It should also work on Carbon (MacOS X).
Probably not on Windows mobile (it has no ShellExecute ?)
So it's not fully cross-platfrom yet.

You can also take a look at: http://bugs.freepascal.org/view.php?id=13574

Bart

Fred vS

  • Hero Member
  • *****
  • Posts: 2727
    • StrumPract is the musicians best friend
Re: How to create a Hyperlink
« Reply #7 on: November 06, 2009, 03:45:35 pm »
Thanks Bart, thanks Leledumbo, thanks Phil  :)
Both browserdetection and Orpheus (not all the tools but URL ok) work very well.

I have now a problem of choice (my favorite problem).
Thanks folk  :D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Raf20076

  • Full Member
  • ***
  • Posts: 150
    • https://github.com/Raf20076
Re: How to create a Hyperlink
« Reply #8 on: October 11, 2014, 10:42:00 pm »
Put on your form TStaticText  component (it would be StaticText1-see code). Then If you want to use hiperlink in your application you must use  lclintf (put in in uses) then use command OpenUrl - see my code.


Code: [Select]

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, lclintf;

type

  { TForm1 }

  TForm1 = class(TForm)
    StaticText1: TStaticText;
    procedure StaticText1Click(Sender: TObject);
    procedure StaticText1MouseEnter(Sender: TObject);
    procedure StaticText1MouseLeave(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }



procedure TForm1.StaticText1Click(Sender: TObject);
begin
  OpenURL('http://www.lazarus.freepascal.org');
{when you click StaticText it will connect to website using default browser.}
end;

procedure TForm1.StaticText1MouseEnter(Sender: TObject);
begin
  StaticText1.Cursor := crHandPoint;
{cursor changes into handshape when it is on StaticText}
  StaticText1.Font.Color := clBlue;
{StaticText changes color into blue when cursor is on StaticText}
end;

procedure TForm1.StaticText1MouseLeave(Sender: TObject);
begin
  StaticText1.Font.Color := clDefault;
{when cursor is not on StaticText then color of text changes into default color}
end;

end.

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: How to create a Hyperlink
« Reply #9 on: October 12, 2014, 08:57:21 pm »
fpGUI includes a TfpgHyperLink widget. You can always take a look at how I did it in fpGUI source code.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: How to create a Hyperlink
« Reply #10 on: October 12, 2014, 09:04:38 pm »
Code: [Select]
uses ... , lclintf;

procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  OpenDocument(TLabel(Sender).Caption);
end;

It's crossplatform and uses OS default browser.

 

TinyPortal © 2005-2018