RichEdit 的 EM_AUTOURLDETECT 消息识别链接,但我无法单击它
我的对话框中有一个 RichEdit 控件。 RichEdit 控件显示 RTF 文本。 EM_AUTOURLDETECT
使 RichEdit 控件正确格式化并识别超链接。当鼠标悬停在链接上时,指针会变为手形,但单击链接后浏览器不会启动。
我是否缺少某种事件处理程序代码?
case WM_INITDIALOG:
{
// Create Richedit
HWND hwndRE = CreateWindowA("RichEdit20A", "", WS_CHILD | WS_BORDER | WS_VSCROLL | ES_READONLY | ES_MULTILINE, 10, 10, 480, 220, hDlgWnd, 0, hInst, 0);
SendMessage(hwndRE ,EM_AUTOURLDETECT,(WPARAM)TRUE,(LPARAM)0);
//SendMessage(hwndRE ,EM_SETEVENTMASK, 1, ENM_LINK | ENM_CHANGE);
ShowWindow(hwndRE, SW_SHOWNORMAL);
SETTEXTEX SetTextEx;
char* aboutdata = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Verdana;}}\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 www.whateverdomain.com} ");
SendMessage(hwndRE, EM_SETTEXTEX,(WPARAM)&SetTextEx, (LPARAM)(LPCTSTR)aboutdata);
return TRUE;
}
I have a RichEdit control in a dialog box. The RichEdit control displays RTF text. EM_AUTOURLDETECT
causes the RichEdit control to properly format and recognize the hyperlink. When the mouse hovers over the link, the pointer changes to a hand, but the browser doesn't launch once the link is clicked.
Am I missing some kind of event handler code?
case WM_INITDIALOG:
{
// Create Richedit
HWND hwndRE = CreateWindowA("RichEdit20A", "", WS_CHILD | WS_BORDER | WS_VSCROLL | ES_READONLY | ES_MULTILINE, 10, 10, 480, 220, hDlgWnd, 0, hInst, 0);
SendMessage(hwndRE ,EM_AUTOURLDETECT,(WPARAM)TRUE,(LPARAM)0);
//SendMessage(hwndRE ,EM_SETEVENTMASK, 1, ENM_LINK | ENM_CHANGE);
ShowWindow(hwndRE, SW_SHOWNORMAL);
SETTEXTEX SetTextEx;
char* aboutdata = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Verdana;}}\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs20 www.whateverdomain.com} ");
SendMessage(hwndRE, EM_SETTEXTEX,(WPARAM)&SetTextEx, (LPARAM)(LPCTSTR)aboutdata);
return TRUE;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试这样的操作:
基本上,当 WM_NOTIFY 代码为 EN_LINK 时,您将获取单击的 URL 并使用 ShellExecute 启动它。
You can try something like this:
Basically, when the WM_NOTIFY code is EN_LINK, you get the clicked URL and launch it using ShellExecute.
查看
EN_LINK
:http ://msdn.microsoft.com/en-us/library/bb787970(VS.85).aspx
Have a look at
EN_LINK
:http://msdn.microsoft.com/en-us/library/bb787970(VS.85).aspx