windows客户端开发--duilib显示html
2016-03-16 20:56
399 查看
今天与大家分享的就是duilib这个库中,如何做到显示html的。
有些控件,如Text可以通过showhtml函数来设置是否显示html富文本。
加粗
斜体
下划线
被选中
换行
链接
这个是最重要的 个人觉得。
有些控件,如Text可以通过showhtml函数来设置是否显示html富文本。
加粗
{b}加粗{/b}
斜体
{i}斜体{/i}
下划线
{u}下划线{/u}
被选中
{s}被选中{/s}
换行
{n}
链接
这个是最重要的 个人觉得。
{a http://www.baidu.com}百度{/a>}[/code]
例如:
输入www.baidu.com {n} {b}加粗{/b} {n} {i}斜体{/i}{n} {u}下划线{/u} {n} {s}被选中{/s}
显示:
最后贴一段duilib中如何处理link的代码:case _T('a'): // Link { pstrText++; while( *pstrText > _T('\0') && *pstrText <= _T(' ') ) pstrText = ::CharNext(pstrText); if( iLinkIndex < nLinkRects && !bLineDraw ) { CDuiString *pStr = (CDuiString*)(sLinks + iLinkIndex); pStr->Empty(); while( *pstrText != _T('\0') && *pstrText != _T('>') && *pstrText != _T('}') ) { LPCTSTR pstrTemp = ::CharNext(pstrText); while( pstrText < pstrTemp) { *pStr += *pstrText++; } } } DWORD clrColor = pManager->GetDefaultLinkFontColor(); if( bHoverLink && iLinkIndex < nLinkRects ) { CDuiString *pStr = (CDuiString*)(sLinks + iLinkIndex); if( sHoverLink == *pStr ) clrColor = pManager->GetDefaultLinkHoverFontColor(); } //else if( prcLinks == NULL ) { // if( ::PtInRect(&rc, ptMouse) ) // clrColor = pManager->GetDefaultLinkHoverFontColor(); //} aColorArray.Add((LPVOID)clrColor); ::SetTextColor(hDC, RGB(GetBValue(clrColor), GetGValue(clrColor), GetRValue(clrColor))); TFontInfo* pFontInfo = pManager->GetDefaultFontInfo(); if( aFontArray.GetSize() > 0 ) pFontInfo = (TFontInfo*)aFontArray.GetAt(aFontArray.GetSize() - 1); if( pFontInfo->bUnderline == false ) { HFONT hFont = pManager->GetFont(pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold, false, pFontInfo->bItalic); if( hFont == NULL ) { hFont = pManager->AddFont(g_iFontID, pFontInfo->sFontName, pFontInfo->iSize, pFontInfo->bBold, false, pFontInfo->bItalic); g_iFontID += 1; } pFontInfo = pManager->GetFontInfo(hFont); aFontArray.Add(pFontInfo); pTm = &pFontInfo->tm; ::SelectObject(hDC, pFontInfo->hFont); cyLine = MAX(cyLine, pTm->tmHeight + pTm->tmExternalLeading + (int)aPIndentArray.GetAt(aPIndentArray.GetSize() - 1)); } ptLinkStart = pt; bInLink = true; } break;
相关文章推荐
- windows客户端开发--duilib显示html
- CharSequence类
- Volley源码学习(三):线程处理request,类CacheDispatcher,NetworkDispatcher,ExecutorDelivery
- iOS UIView animation动画效果 (1)
- easyui 列表里下拉框联动
- UI进阶——SQL数据库
- android:finishOnTaskLaunch="true" //虽然这样设置了,但是Back键与Home键还是不同
- torque
- 给UIButton设置BackgroundColor:forState
- guice框架的入门使用
- (4.5.3.4)finished with non-zero exit value 2
- UI组件:PopupWindows的详细使用(一)
- U3D打包DLL插件 DLL Builder
- UITableView传值(自己使用)(属性,代理传值)
- iOS UITextField设置金额(钱数)输入框
- iOS--页面跳转(UITableView)
- NGUI中打字效果TypewriterEffect的一个BUG
- POJ 2229 Ultra-QuickSort 归并排序求逆序数
- Number Sequence (HDU_1711) KMP
- build模式小例子