Forum > Beginners

Hyperlink labels [SOLVED]

(1/5) > >>

pascal111:
لديّ هذه المحاولة البسيطة لعمل نموذج form يحوي بعض الروابط ولكن المشكلة هي أنّني أودّ عندما أنقر على الرابط أن ينفتح في مُستعرض الويب.

google translate:

"I have this simple attempt to create a form that contains some links, but the problem is "I want" that when I click on the link, it opens in my web browser."


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin   label1.Caption:='Arabic FaceBook: https://www.facebook.com/people/Ahmed-Crow/100009232142912/';  label2.Caption:='English FaceBook: https://www.facebook.com/ahmed.crow.988/';  label3.Caption:='Blog: https://paracletus0de0evangelio.blogspot.com/';end;     

Handoko:
I haven't tried but I know you can open a link by using:
https://wiki.freepascal.org/Webbrowser#OpenURL

So you need to put the OpenURL command inside the TLabel.OnClick event.

howardpc:
Generate an OnClick handler for each label by double-clicking on it in the object inspector.
Then add code such as
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  LCLIntf;procedure TForm1.Label1Click(Sender: TObject);begin  OpenURL(Copy(Label1.Caption, 18, MaxInt));end;The other labels will need a different value from "18" of course.

pascal111:

--- Quote from: Handoko on May 18, 2021, 06:46:55 pm ---I haven't tried but I know you can open a link by using:
https://wiki.freepascal.org/Webbrowser#OpenURL

So you need to put the OpenURL command inside the TLabel.OnClick event.

--- End quote ---

نعم كما في مثال @howardpc

google translate:

"Yes, as in the @howardpc example"

pascal111:

--- Quote from: howardpc on May 18, 2021, 06:48:48 pm ---Generate an OnClick handler for each label by double-clicking on it in the object inspector.
Then add code such as
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  LCLIntf;procedure TForm1.Label1Click(Sender: TObject);begin  OpenURL(Copy(Label1.Caption, 18, MaxInt));end;The other labels will need a different value from "18" of course.

--- End quote ---

لماذا إستخدمتَ MaxInt بالرغم أنّها الحد الأقصى للقيمة الصحيحة كما في الرابط https://wiki.freepascal.org/maxint أم تعني أنّها الحد الأقصى كذلكـ لطول القيمة الحرفيّة في الـ label.caption؟

google translate:

"Why do you use MaxInt even though it is the maximum valid "integer type" value as in https://wiki.freepascal.org/maxint or does it mean that it is also the maximum length of the literal "string" value in the label.caption?"

Navigation

[0] Message Index

[#] Next page

Go to full version