TRichEdit中设置EM_AUTOURLDETECT后如何检测URL链接?
我正在尝试使用 EM_AUTOURLDETECT 消息为 TRichEdit 组件实现 URL 检测。
我对以下代码有疑问
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;
它虽然可以工作,但我必须在这些设置之后更改 TRichEdit 的文本,以使其检测已写入文本中的 URL。这就是问题所在,因为应用此功能时我的 TRichEdit 处于只读模式。
执行此代码以强制 TRichEdit 检测已写入文本中的 URL 后我应该做什么?
我正在查看文档< /a> 但没有提到类似的事情。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我前段时间遇到过同样的问题,并使用了(相当)肮脏的解决方法。
发送
后EM_AUTOURLDETECT
消息我获取并存储当前选择,然后(重新)设置丰富编辑的文本并设置回之前存储的选择。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.