RichEdit does not process hyperlinks
<p>I want my RichEdit to process hyperlinks, so I followed the instructions on: <a href="http://delphi.about.com/od/vclusing/l/aa111803a.htm" rel="nofollow">http://delphi.about.com/od/vclusing/l/aa111803a.htm</a>  </p>

<p>Here are the changes I made to the code:</p>

<pre><code>interface

type
  TProgCorner = class(TForm)
    RichEdit2: TRichEdit;
    RichEdit1: TRichEdit;
    RichEdit3: TRichEdit;
    RichEdit4: TRichEdit;
    procedure FormCreate(Sender: TObject);
  private
    procedure InitRichEditURLDetection(RE: TRichEdit);
  protected
    procedure WndProc(var Msg: TMessage); override;
  end;

implementation

{$R *.DFM}

uses
  ShellAPI, RichEdit;

const
  AURL_ENABLEURL = 1;
  AURL_ENABLEEAURLS = 8;

procedure TProgCorner.InitRichEditURLDetection(RE: TRichEdit);
var
  mask: LResult;
begin
  mask := SendMessage(RE.Handle, EM_GETEVENTMASK, 0, 0);
  //In the debugger mask is always 1, for all 4 Richedits.
  SendMessage(RE.Handle, EM_SETEVENTMASK, 0, mask or ENM_LINK); 
  //returns 67108865
  SendMessage(RE.Handle, EM_AUTOURLDETECT, AURL_ENABLEURL, 0);
  //Returns 0 = success (according to MSDN), but no joy.
  //SendMessage(RE.Handle, EM_AUTOURLDETECT, AURL_ENABLEEAURLS, 0); 
  //When uncommented returns -2147024809
  //I don't think the registration works, but don't know how to fix this.
end;

procedure TProgCorner.WndProc(var Msg: TMessage);
var
  p: TENLink;
  sURL: string;
  CE: TRichEdit;
begin
  //'normal' messages do get through here, but...
  if (Msg.Msg = WM_NOTIFY) then begin
    //...the following line is never reached.
    if (PNMHDR(Msg.lParam).code = EN_LINK) then begin
      p:= TENLink(Pointer(TWMNotify(Msg).NMHdr)^);
      if (p.Msg = WM_LBUTTONDOWN) then begin
        try
          CE:= TRichEdit(ProgCorner.ActiveControl);
          SendMessage(CE.Handle, EM_EXSETSEL, 0, LPARAM(@(p.chrg)));
          sURL:= CE.SelText;
          ShellExecute(Handle, 'open', PChar(sURL), 0, 0, SW_SHOWNORMAL);
        except
          {ignore}
        end;
      end;
    end;
  end;

 inherited;
end;

procedure TProgCorner.FormCreate(Sender: TObject);
begin
  InitRichEditURLDetection(RichEdit1);
  InitRichEditURLDetection(RichEdit2);
  InitRichEditURLDetection(RichEdit3);
  InitRichEditURLDetection(RichEdit4);
  //If I set the text here (and not in the object inspector) 
  //the richedit shows a hyperlink with the 'hand' cursor.
  //but still no WM_notify message gets received in WndProc.
  RichEdit1.Text:= 'http://www.example.com';

end;

end.
</code></pre>

<p>However the hyperlinks that I embedded into my <code>RichEditx.Lines</code> using the object inspector show up as plain text (not links) and clicking on them does not work.  </p>

<p>I'm using Delphi Seattle running on Windows 7 in Win32 mode.</p>

<p>What am I doing wrong?  </p>

<p><strong>UPDATE</strong><br>
Using a combination of issuing the deprecated<br>
<code>SendMessage(RE.Handle, EM_AUTOURLDETECT, AURL_ENABLEURL, 0);</code> and setting the <code>RichEditx.Text:= 'http://www.example.com'</code> manually in <code>FormCreate</code> I am able to have the Richedit display a hyperlink and handcursor.<br>
However the WndProc still does not receive a <code>WM_Notify</code> message.<br>
The WndProc does receive other messages.  </p>

<p><strong>UPDATE2</strong><br>
In my eagerness to simplify the issue I left out the fact that the <code>RichEdit</code> sits on top of a <code>Panel</code>. The panel eats the <code>WM_Notify</code> messages so they don't reach the form underneigh.   </p>