I'm trying to implement URL detection for TRichEdit component using EM_AUTOURLDETECT message.
I have a problem with the following code
procedure TForm1.Button1Click(Sender: TObject);
var Mask: Word;
begin
Mask := SendMessage(Handle, EM_GETEVENTMASK, 0, 0);
SendMessage(Handle, EM_SETEVENTMASK, 0, Mask or ENM_LINK);
SendMessage(Handle, EM_AUTOURLDETECT, Integer(True), 0);
end;
It works though but I have to change the TRichEdit's text after these settings to get the it detect the URLs in already written text. And that's the problem because my TRichEdit is in ReadOnly mode when applying this feature.
What should I do after performing this code to force the TRichEdit to detect URLs in already written text ?
I was looking at the documentation but there's no mention about something like this.
Thank you
I've had the same problem some time ago and used (quite) a dirty workaround for it. After sending of the
EM_AUTOURLDETECT
message I get and store the current selection, then (re)set the rich edit's text and set back the selection stored before.