今天与大家分享的就是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. java线程系列文章之一(线程的安全性)

    本文来自:高爽|Coder,原文地址:http://blog.csdn.net/ghsau/article/details/7421217,转载请注明. 当我们查看JDK API的时候,总会发现一些类 ...

  2. BZOJ 4197 NOI 2015 寿司晚宴 状压DP

    4197: [Noi2015]寿司晚宴 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 694  Solved: 440[Submit][Status] ...

  3. window.open如何返回值给父窗口

    父窗口代码 function showMyWindowNew() { var iTop = (window.screen.availHeight - 30 - 450) / 2; //获得窗口的水平位 ...

  4. Codeforces Round #254 (Div. 1) D. DZY Loves Strings hash 暴力

    D. DZY Loves Strings 题目连接: http://codeforces.com/contest/444/problem/D Description DZY loves strings ...

  5. HDU 2553 N皇后问题(深搜DFS)

    N皇后问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  6. hdoj 1002 A + B Problem II 高精度 java

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  7. SlickSafe.NET 开源权限框架开发指南

    前言:本文适用于快速搭建权限系统的用户,尤其适用于希望有良好定义的权限模型建立:系统解决方案是在基于角色访问控制(RBAC)策略基础上的权限访问模型实现,主要完成了后台权限验证逻辑和前端权限数据验证的 ...

  8. How to install WP 8.0 SDK if WP 8.1 SDK is installed?

    I have the Windows Phone 8.1 SDK on my dev pc installed together with VS 2013. I need to open some W ...

  9. [MSDN] Windows Server 2012 R2 简/繁/英下载

    Windows Server 2012 R2 Chinese-Simplified ISO SHA1-------------------------------------------------- ...

  10. StringBuilder和StringBuffer解析(百度面试题优化须要用到的)

    StringBuilder是java5及以后提供的API,它不是线程安全的,而StringBuffer是java1.4曾经的API,它是线程安全的,所以说StringBuilder的效率更高一些,今天 ...