windowsclient开发--duilib显示html
今天与大家分享的就是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的更多相关文章
- WinForm开发,窗体显示和窗体传值相关知识总结
主窗体中代码: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void b ...
- windowsclient开发--怎样測量一个字符串显示的物理长度
首先须要说明的是,我所说的字符串的长度,不是string的length,也不是string的size.我指的是显示的长度.即物理长度. 缘由: 之所以要提到这个.是由于遇到了一些问题. 再使用duil ...
- IOS开发之显示微博表情
在上一篇博客中山寨了一下新浪微博,在之后的博客中会对上一篇代码进行优化和重用,上一篇的微博请求的文字中有一些表情没做处理,比如带有表情的文字是这样的“我要[大笑],[得意]”.显示的就是请求的字符串, ...
- Windowsclient开发简单介绍(四)
在上一篇文章里,我简单扼要的给大家介绍了一下GDI的基础知识,包含DC,HDC.GDI对象等等,总的来说都是些偏理论的知识,属于概念的范畴. 今天这篇文章里,我就要正式開始有点实际的东 ...
- windowsclient开发--为你的client进行国际化
之前博客讲过函数: GetUserDefaultUILanguage Returns the language identifier for the user UI language for the ...
- windowsclient开发--使用、屏蔽一些快捷键
每一个windowsclient都有自己的一些快捷键,有的是windows系统提供的. 今天就要与大家分享一下.在windowsclient开发过程中对按键的处理. ESC按键 Duilib这个库中, ...
- World Wind Java开发之三 显示状态栏信息
先来看下本篇博客索要达到的效果: 找到源代码下的gov.nasa.worldwind.util下的StatusBar.java文件,能够看到状态栏显示的信息主要包含视点高度以及相应空间点三维坐标以及是 ...
- World Wind Java开发之三 显示状态栏信息(转)
http://blog.csdn.net/giser_whu/article/details/40920315 先来看下本篇博客索要达到的效果: 找到源码下的gov.nasa.worldwind.ut ...
- windowsclient开发--使你的client执行时记住上次关闭的大小和位置
差点儿全部的windowsclient都能够调整大小,所以用户依据自己的喜好调整client的大小和位置. 可是当该client退出后,又一次执行client的时候.我们往往又要调整自己喜好的大小和位 ...
随机推荐
- Java_基础知识回顾
1.ByteArrayInputStream. ByteArrayOutputStream String str = "ZHANGSAN"; //System.out.printl ...
- String对象池的作用
我们知道得到String对象有两种办法:String str1="hello";String str2=new String("hello"); 这两种 ...
- 将一张表中的字段更新到另一张表的sql
UPDATE tb_user a INNER JOIN tb_doctor s ON s.id=a.id SET a.AVATAR=s.AVATAR UPDATE tb_user a INNER JO ...
- linux-修改时区时间
所有笔记基于-CentOS release 6.8 (Final) ntpdate 202.120.2.101 同步上海时间 cp -f /usr/share/zoneinfo/Asia/Shangh ...
- unity 质量设置 Quality Settings
Unity allows you to set the level of graphical quality it will attempt to render. Generally speaking ...
- StringUtils类常用方法介绍
StringUtils方法包的位置:org.apache.commons.lang.StringUtils StringUtils 方法的操作对象是 java.lang.String 类型的对象,是 ...
- RHPAM 7.2安装
1.产品架构 2.安装过程 下载相应介质 JBoss EAP (jboss-eap-7.2.0.zip) 下载地址 https://developers.redhat.com/products/e ...
- MapReduce编程基础
MapReduce编程基础 1. WordCount示例及MapReduce程序框架 2. MapReduce程序执行流程 3. 深入学习MapReduce编程(1) 4. 参考资料及代码下载 & ...
- Flask 学习(三)模板
Flask 学习(三)模板 Flask 为你配置 Jinja2 模板引擎.使用 render_template() 方法可以渲染模板,只需提供模板名称和需要作为参数传递给模板的变量就可简单执行. 至于 ...
- 15、高可用 PXC(percona xtradb cluster) 搭建
安装环境: 集群名 pxc_lk 节点1: 192.168.1.20 节点2: 192.168.1.21 节点3: 192.168.1.22 所有节点安装 wget http://www.perc ...