Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 675469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:49:17+00:00 2026-05-14T00:49:17+00:00

I am trying to update RichEdit so that it detects URL and enables clicking

  • 0

I am trying to update RichEdit so that it detects URL and enables clicking on it to open in the browser. Detecting URL is easy, I just use the following code from http://www.scalabium.com/faq/dct0146.htm

mask := SendMessage(MNote.Handle, EM_GETEVENTMASK, 0, 0);
  SendMessage(MNote.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK);
  SendMessage(MNote.Handle, EM_AUTOURLDETECT, Integer(True), 0); 

but the second part doesn’t work for me. They give the following code to capture EN_LINK message and processing it:

type
  TForm1 = class(TForm)
  protected
    procedure WndProc(var Message: TMessage); override;
  end;
...

procedure TForm1.WndProc(var Message: TMessage);
var
  p: TENLink;
  strURL: string;
begin
  if (Message.Msg = WM_NOTIFY) then
  begin
    if (PNMHDR(Message.LParam).code = EN_LINK) then
    begin
      p := TENLink(Pointer(TWMNotify(Message).NMHdr)^);
      if (p.msg = WM_LBUTTONDOWN) then
      begin
        SendMessage(RichEdit1.Handle, EM_EXSETSEL, 0, LongInt(@(p.chrg)));
        strURL := RichEdit1.SelText;
        ShellExecute(Handle, 'open', PChar(strURL), 0, 0, SW_SHOWNORMAL);
      end
    end
  end;

  inherited;
end;

When I run the program, URL is detected, but clicking on it doesn’t do anything. Using debug I found out that Message.Msg = WM_NOTIFY is not true when I click on URL. I then tried to override TRichEdit’s WndProc, but result is the same. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:49:17+00:00Added an answer on May 14, 2026 at 12:49 am

    Subclass the RichEdit’s WindowProc property and look for the CN_NOTIFY message, for example:

    type
      TForm1 = class(TForm)
        RichEdit1: TRichEdit;
        procedure FormCreate(Sender: TObject);
      private
        PrevRichEditWndProc: TWndMethod;
        procedure RichEditWndProc(var Message: TMessage);
        procedure SetRichEditMasks;
      end; 
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      PrevRichEditWndProc := RichEdit1.WindowProc;
      RichEdit1.WindowProc := RichEditWndProc;
      SetRichEditMasks;
    end;
    
    procedure TForm1.SetRichEditMasks;
    var
      mask: Longint;
    begin
      mask := SendMessage(RichEdit1.Handle, EM_GETEVENTMASK, 0, 0); 
      SendMessage(RichEdit1.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK); 
      SendMessage(RichEdit1.Handle, EM_AUTOURLDETECT, 1, 0);  
    end;
    
    procedure TForm1.RichEditWndProc(var Message: TMessage); 
    begin 
      PrevRichEditWndProc(Message);
      case Message.Msg of
        CN_NOTIFY:
          begin
            if (TWMNotify(Message).NMHdr^.code = EN_LINK) then
            begin
              with PENLink(Message.LParam)^ do
              begin
                if (msg = WM_LBUTTONDOWN) then
                begin 
                  SendMessage(RichEdit1.Handle, EM_EXSETSEL, 0, LongInt(@chrg)); 
                  ShellExecute(Handle, 'open', PChar(RichEdit1.SelText), 0, 0, SW_SHOWNORMAL); 
                end;
              end;
            end;
          end;
        CM_RECREATEWND:
          begin
            SetRichEditMasks;
          end;
      end; 
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to update a table with the following code. If I change WHERE
When trying to update a subversion working copy from Netbeans, I get the following
I'm trying to update my code to use cv2.SURF() as opposed to cv2.FeatureDetector_create(SURF) and
Im trying to update some nested params from a form. I can see that
Trying to update some repositories on Debian Etch installation and getting the following errors
Trying to update to a pointer from a function return. Just for background this
I was trying to update the Recently Changed App by adding the columns that
I was trying to update a framework that we used before, since they had
Trying to update a table so that a field has it's contents changed to
I'm trying to update the innerHTML of a div tag that's within the parent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.