今天与大家分享的就是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;

windowsclient开发--duilib显示html的更多相关文章

  1. WinForm开发,窗体显示和窗体传值相关知识总结

    主窗体中代码: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void b ...

  2. windowsclient开发--怎样測量一个字符串显示的物理长度

    首先须要说明的是,我所说的字符串的长度,不是string的length,也不是string的size.我指的是显示的长度.即物理长度. 缘由: 之所以要提到这个.是由于遇到了一些问题. 再使用duil ...

  3. IOS开发之显示微博表情

    在上一篇博客中山寨了一下新浪微博,在之后的博客中会对上一篇代码进行优化和重用,上一篇的微博请求的文字中有一些表情没做处理,比如带有表情的文字是这样的“我要[大笑],[得意]”.显示的就是请求的字符串, ...

  4. Windowsclient开发简单介绍(四)

            在上一篇文章里,我简单扼要的给大家介绍了一下GDI的基础知识,包含DC,HDC.GDI对象等等,总的来说都是些偏理论的知识,属于概念的范畴. 今天这篇文章里,我就要正式開始有点实际的东 ...

  5. windowsclient开发--为你的client进行国际化

    之前博客讲过函数: GetUserDefaultUILanguage Returns the language identifier for the user UI language for the ...

  6. windowsclient开发--使用、屏蔽一些快捷键

    每一个windowsclient都有自己的一些快捷键,有的是windows系统提供的. 今天就要与大家分享一下.在windowsclient开发过程中对按键的处理. ESC按键 Duilib这个库中, ...

  7. World Wind Java开发之三 显示状态栏信息

    先来看下本篇博客索要达到的效果: 找到源代码下的gov.nasa.worldwind.util下的StatusBar.java文件,能够看到状态栏显示的信息主要包含视点高度以及相应空间点三维坐标以及是 ...

  8. World Wind Java开发之三 显示状态栏信息(转)

    http://blog.csdn.net/giser_whu/article/details/40920315 先来看下本篇博客索要达到的效果: 找到源码下的gov.nasa.worldwind.ut ...

  9. windowsclient开发--使你的client执行时记住上次关闭的大小和位置

    差点儿全部的windowsclient都能够调整大小,所以用户依据自己的喜好调整client的大小和位置. 可是当该client退出后,又一次执行client的时候.我们往往又要调整自己喜好的大小和位 ...

随机推荐

  1. [BZOJ4237]稻草人/[JOISC2014]かかし

    [BZOJ4237]稻草人/[JOISC2014]かかし 题目大意: 平面上\(n(n\le2\times10^5)\)个点,若一个矩形各边与坐标轴平行,左下角和右上角都在\(n\)个点之中,且内部不 ...

  2. [POJ1082]Calendar Game

    题目大意: 日历上博弈,从给定的日期,按照下述规则跳转日期: 1.跳到第二天: 2.调到下个月相同的日期(如果没有就不能跳转). 刚刚好跳到2001年11月4日的人胜,跳转时不能跳到2001年11月4 ...

  3. 【洛谷】NOIP提高组模拟赛Day2【动态开节点/树状数组】【双头链表模拟】

    U41571 Agent2 题目背景 炎炎夏日还没有过去,Agent们没有一个想出去外面搞事情的.每当ENLIGHTENED总部组织活动时,人人都说有空,结果到了活动日,却一个接着一个咕咕咕了.只有不 ...

  4. codevs 1204 寻找子串位置 KMP

    1204:寻找子串位置 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 18K  Solved: 8K Description 给出字符串a和字符串b,保 ...

  5. Codeforces Round #287 (Div. 2) A. Amr and Music 水题

    A. Amr and Music time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. CodeForces 81D.Polycarp's Picture Gallery 乱搞

    D. Polycarp's Picture Gallery time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  7. GPS坐标定位与距离计算

    Android获取当前位置(GPS和网络定位) 1.比较: GPS准确度高但耗电多,网络定位耗电少但准确度低 2.代码 ①添加权限: AndroidManifest.xml: <!-- 两种pr ...

  8. DEX 可视化查阅

    参考: http://bbs.pediy.com/thread-208828.htm 010 Editor 下载地址: http://www.sweetscape.com/download/ //-- ...

  9. SmartProg2 Universal, ISP capable programmer

    http://www.elnec.com/products/universal-programmers/smartprog2/ 40 powerful TTL pindrivers provide H ...

  10. C 常量的类型

    http://bbs.csdn.net/topics/380028485 整型常量的类型是下列相应表中第一个能表示其值的类型: int --> long int --> long long ...