Detecting URLs in TMemo

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.
sharonsAsked:
Who is Participating?
 
BlackManConnect With a Mentor Commented:
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
 
BlackManCommented:
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
 
MatveyCommented:
What identifies a URL? Just the "http://"?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
sharonsAuthor Commented:
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
 
BlackManCommented:
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
 
BlackDeathCommented:
who is sharons?
(your profile doesn't tell too much)
BlackMan's comment's it.

cheers,
Black Death.
0
 
binkzzCommented:
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
 
sharonsAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.