Solved

Detecting URLs in TMemo

Posted on 1998-08-30
8
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 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