博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
windowsclient开发--duilib显示html
阅读量:7280 次
发布时间:2019-06-30

本文共 2883 字,大约阅读时间需要 9 分钟。

今天与大家分享的就是duilib这个库中,怎样做到显示html的。

有些控件,如Text能够通过showhtml函数来设置是否显示html富文本。

加粗

{b}加粗{/b}

斜体

{i}斜体{/i}

下划线

{u}下划线{/u}

被选中

{s}被选中{/s}

换行

{n}

链接

这个是最重要的 个人认为。

{
a http://www.baidu.com}百度{/a>}

比如:

输入
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;
你可能感兴趣的文章
MYSQL外键(Foreign Key)的使用
查看>>
导入开源库到基于Android Studio构建的项目中
查看>>
Maven 在eclispe中集成本地插件报错解决方案
查看>>
Ubuntu中必装的十个应用程序
查看>>
Object-c 单例模式中的 allocWithZone作用
查看>>
分享一个H5原生form表单的checkbox特效
查看>>
nodejs+npm+webpack+vue+ElementUI+vue-route
查看>>
JAVA编程插入Excel文件到Word数据区域
查看>>
Highcharts 3.0.8功能特性使用评测
查看>>
大型分布式网站架构实战项目分析
查看>>
python 图片处理 窗体
查看>>
游戏开发--开源软件6--LimeJS(javascript)||Gamvas||gamejs
查看>>
Android四种常用的消息传递机制/模式的比较
查看>>
我的友情链接
查看>>
五虎遁月 和 五鼠遁时 法
查看>>
很好的一个blog,记录一下
查看>>
关于mysql修复表
查看>>
DBWn与物理写
查看>>
ajax实现的动态展开
查看>>
python 与数据结构
查看>>