Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create URL highlighting in TRichEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-May-03
Category
Reporting /Printing
Language
Delphi 2.x
Views
73
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Attila T.P.

URL highlighting in TRichEdit

Answer:

This functionality is implemented in RichEdit from Microsoft (and MS Outlook use 
this feature, for example) and 
only Borland's developers didn't publish it for us.)

1   protected
2   
3   procedure WndProc(var message: TMessage); override;
4   
5   {....}
6   
7   uses Richedit, ShellApi;
8   
9     procedure TForm1.FormCreate(Sender: TObject);
10    var
11      mask: Word;
12    begin
13      mask := SendMessage(RichEdit1.Handle, EM_GETEVENTMASK, 0, 0);
14      SendMessage(RichEdit1.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
15      SendMessage(RichEdit1.Handle, EM_AUTOURLDETECT, Integer(True), 0);
16  
17      //Some text in RichEdit
18      RichEdit1.Text := 'Scalabium Software'#13#10 +
19        ' Site is located at www.scalabium.com. Welcome to our site.';
20    end;
21  
22    procedure TForm1.WndProc(var message: TMessage);
23    var
24      p: TENLink;
25      strURL: string;
26    begin
27      if (message.Msg = WM_NOTIFY) then
28      begin
29        if (PNMHDR(message.lParam).code = EN_LINK) then
30        begin
31          p := TENLink(Pointer(TWMNotify(message).NMHdr)^);
32          if (p.Msg = WM_LBUTTONDOWN) then
33          begin
34            SendMessage(RichEdit1.Handle, EM_EXSETSEL, 0, Longint(@(p.chrg)));
35            strURL := RichEdit1.SelText;
36            ShellExecute(Handle, 'open', PChar(strURL), 0, 0, SW_SHOWNORMAL);
37          end
38        end
39      end;
40  
41      inherited;
42    end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC