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

本文共 2936 字,大约阅读时间需要 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;

转载于:https://www.cnblogs.com/cxchanpin/p/7352940.html

你可能感兴趣的文章
剑指Offer学习笔记(3)——解决面试题的思路
查看>>
.NET Framework基础知识(二)(转载)
查看>>
Yii DataProvider
查看>>
BestCoder Round #14 B 称号 Harry And Dig Machine 【TSP】
查看>>
hdu 1114 Piggy-Bank
查看>>
maven集成tomcat插件启动报错
查看>>
Boost库编译安装
查看>>
Python matplot画散列图
查看>>
C#/.NET整数的三种强制类型转换(int)、Convert.ToInt32()、int.Parse()的区别
查看>>
算法复习——数位dp(不要62HUD2089)
查看>>
PhpSpreadsheet如何读取excel文件
查看>>
如何选购一款好的人事档案管理系统
查看>>
Spark2.1.0——运行环境准备
查看>>
[转载]C#异步调用四大方法详解
查看>>
在windows下添加php的Imagick扩展
查看>>
python3 爬取百合网的女人们和男人们
查看>>
kubernetes源码阅读笔记——Kubelet(之三)
查看>>
如何利用jQuery post传递含特殊字符的数据
查看>>
中国剩余定理
查看>>
Codeforces 543.B Destroying Roads
查看>>