Solved

Detecting URLs in TMemo

Posted on 1998-08-30
8
344 Views
Last Modified: 2012-05-04
I am using a TMemo in a mail client. I would like to implement the function of having URLs in the TMemo become links that can be clicked to launch web browser.
0
Comment
Question by:sharons
8 Comments
 
LVL 7

Expert Comment

by:BlackMan
ID: 1338174
If you want to use TMemo, I think you have some hard work to do. Instead you can switch to RichEdit v2, it has a AutoURLDetect property. There is an example on www.torry.com on how to use it.

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1338175
What identifies a URL? Just the "http://"?
0
 

Author Comment

by:sharons
ID: 1338176
Thank you. I tried to find that example in Torry's but could not find it. Is it in Examples or is it with a component ?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:BlackMan
ID: 1338177
You can find the example under "Components / Edit,Memos #2" with the name TRichEdit98.
Direct download is www.torry.com/vcl/edits/richedit98.zip

0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1338178
who is sharons?
(your profile doesn't tell too much)
BlackMan's comment's it.

cheers,
Black Death.
0
 
LVL 4

Expert Comment

by:binkzz
ID: 1338179
You can of course do it the 'hard' way, which would be :

procedure findurl(sender: Tobject);
const url = 'http://';
var urlpos : array[1..100,1..100] of boolean;
for i := 1 to memo.lines do
begin
  for j := 1 to length(memo.lines[i]) - 6 do
  begin
    if copy(memo.lines[i],j,length(url)) = url then urlpos[j, i] := true;
    memo2.lines.add('url found on line ' + inttostr(i) + ' at position + ' inttostr(j));
  end;
end;

You can cut pieces out of there to make it a one line function, which might be easier to find.
0
 

Author Comment

by:sharons
ID: 1338180
Thank you all. I used Blackmans suggestion to use TRichEditV2 from Torry and it works great. One thing I did not include in the description of the problems is that I also want to be able to click on these links and invoke the Web Browser. TRichEditV2 does just that.  So I guess the points should go to BlackMan.
0
 
LVL 7

Accepted Solution

by:
BlackMan earned 70 total points
ID: 1338181
If you want to use TMemo, I think you have some hard work to do. Instead you can switch to RichEdit v2, it has a AutoURLDetect property. There is an example on www.torry.com on how to use it.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question