分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
系统环境:Windows 7
软件环境:Visual Studio 2008 SP1
本次目的:实现Syslink Control超链接的效果
我们知道在VS2008中,VC里面多了syslink controls,command 、 split buttons 和 network address controls。对于Syslink Control的使用,将在此介绍。目前该控件支持带HREF 和 ID的锚定标记<a>,MSDN如下说明:
An HREF may be of any protocol, such as http, ftp, mailto, and so on. An ID is an optional name unique within a SysLink control and associated with an individual link. Links are also assigned a zero-based index according to their position within the string. This index is used to access a link.
首先:建立一个对话框工程,添加一个Syslink Control控件;
然后,为控件添加CLinkCtrl类的变量,这里名称为m_Link。在对话框初始化函数OnInitDialog()里面添加以下代码:
- m_Link.SetWindowText(_T("欢迎光临<a href="/" mce_href="/""http://blog.csdn.net/akof1314/">无幻博客</a>"));
上面代码中的格式要注意,记得转义字符的使用。接着,为控件添加 NM_CLICK事件,在事件函数里面添加如下:
- void CTestDlg::OnNMClickSyslink1(NMHDR *pNMHDR, LRESULT *pResult)
- {
- // TODO: 在此添加控件通知处理程序代码
- PNMLINK pNMLink = (PNMLINK) pNMHDR;
- if (wcscmp(pNMLink->item.szUrl, _T("http://blog.csdn.net/akof1314")) == 0)
- {
- ShellExecuteW(NULL, L"open", pNMLink->item.szUrl, NULL, NULL, SW_SHOWNORMAL); //主要执行语句
- }
- *pResult = 0;
- }
效果如下:
更多的信息,可以在这个博客查询:http://mariusbancila.ro/blog/2007/07/05/syslink-control-in-mfc-90/
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)