在记事本中创建HyperLink(textEdit)[MFC] [英] Creating HyperLink in Notepad(textEdit)[MFC]

查看:85
本文介绍了在记事本中创建HyperLink(textEdit)[MFC]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MFC构建textEdit应用程序.当用户输入网址时,是否可以自动创建超链接?就像您编写网址"www.google.com"时,应用程序会检测到网址并立即创建超链接.我搜索了解释此问题的文档,但找不到它. 而且我做不到. 我已经做过记事本,但是无法在记事本上添加超链接功能.

I am building a textEdit application with MFC. Is there a way to create a hyperlink automatically when a user write web address? It's like when you write a web address "www.google.com" the application detects web address and create a hyperlink right away. I have searched documents that explains about this, but couldn't find it.. and i couldn't make it.. i already have made notepad but i couldn't add the function of hyperlink on the notepad.

以下句子是超链接的功能.

the following sentences are functions of hyperlink.

  1. 单击文本需要在浏览器窗口中打开由文本指定的位置.

  1. Clicking the text needs to open a browser window to the location specified by the text.

在控件上移动时,光标需要从标准箭头光标更改为指向食指.

The cursor needs to change from the standard arrow cursor to a pointing index finger when it moves over the control.

当光标移到控件上方时,控件中的文本需要加下划线.

The text in the control needs to be underlined when the cursor moves over the control.

超链接控件需要以不同的颜色显示文本,而黑色则不会. 我添加的功能是:

A hyperlink control needs to display text in a different color—black just won't do. The features that I added are:

5.一次访问过的超链接控件需要更改颜色.

5.A hyperlink control once visited needs to change color.

6.应该可以通过键盘访问超链接控件.

6.The hyperlink control should be accessible from the keyboard.

7.它应该安装某种钩子,以便程序员在控件具有焦点时或光标悬停在控件上时可以执行某些操作.

7.It should install some kind of hooks to allow the programmer to perform some actions when the control has the focus or when the cursor is hovering over the control.

在功能中,我最想完成的是第一个. 如果我单击超链接文本,则应将其链接到Internet上的浏览器窗口.

Among the functions, What I mostly want to complete is the first one. If I click a Hyperlink text, it should be linked to a browser window on the Internet.

请回答并帮助我.谢谢.

Please answer and help me. Thanks.

推荐答案

只需使用 SetAutoURLDetect .完成.

Just use a CRichEditCtrl control (remember to call AfxInitRichEdit2 in your InitInstance). Call SetAutoURLDetect. Done.

这篇关于在记事本中创建HyperLink(textEdit)[MFC]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆