xml: <Text text=":{c #9900E9}{a https://www.baidu.com/}跳转1{/a}第一次写博客{a http://bbs.csdn.net/home}跳转2{/a}{/c}" showhtml="true" />
代码:
if (msg.sType == DUI_MSGTYPE_LINK)
{
CTextUI* pText=(CTextUI*)msg.pSender;
CStringUI* str = pText->GetLinkContent(msg.ptMouse);
//如果点击的是“跳转1”,str就等于https://www.baidu.com/
//如果点击的是“跳转2”,str就等于http://bbs.csdn.net/home
//打开浏览器
ShellExecute(NULL, "open", str->GetData(), NULL, NULL, SW_SHOWNORMAL);
}
注意CTextUI要添加代码
CStringUI* CTextUI::GetLinkContent( const POINT& ptMouse )
{
int i = 0;
for(; i < m_nLinks; i++)
{
if(::PtInRect(&m_rcLinks[i], ptMouse))
break;
}
return GetLinkContent(i);
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wclaccp/article/details/51119665