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的时候.我们往往又要调整自己喜好的大小和位 ...
随机推荐
- 某谷 P5159 WD与矩阵
题面在这里 崴脚回家后的小休闲2333. 显然每一行的1的个数必须是偶数,这样可以归纳证明前i行异或出来的m位二进制数也有偶数个1,这样最后一行就有且仅有一种放法了. 于是ans = 2^((n-1) ...
- Tomcat启动异常 java.net.BindException: Cannot assign requested address: JVM_Bind
从Apache官网下载的tomcat7,在MyEclipse中启动时抛出如下异常: 严重: StandardServer.await: create[localhost:8005]: java.net ...
- 快速搭建简单的LBS程序——地图服务
很多时候,我们的程序需要提供需要搭建基于位置的服务(LBS),本文这里简单的介绍一下其涉及的一些基本知识. 墨卡托投影 地图本身是一个三维图像,但在电脑上展示时,往往需要将其转换为二维的平面图形,需要 ...
- Leetcode 树 Populating Next Right Pointers in Each Node II
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie Populating Next Right Pointers in Each Node II ...
- RAD Studio 2010~XE8 官方 ISO 下载地址 (2015-03-28更新)
http://bbs.csdn.net/topics/390816856 RAD Studio XE8 目前最新版 v22.0.19027.8951 官方 ISO 文件下载(6.72GB):http: ...
- sunstudio 12.3 on solaris 10
#include <stdio.h> #include <stdlib.h> #define RPT 10000000 int main() { int i=1; for( i ...
- [android]ShareSDK——内容分享和短信验证
前言 新版本号ShareSDK的分享和短信验证,按官网的文档,都须要加入一个<Activity></Activity>标签,而分享和短息验证的这个标签内容都一样.会冲突. 解决 ...
- C#关键字var是什么,在何种情况下使用
从.NET 3.0开始,在方法内部可以使用var关键字声明局部变量.var关键字到底是什么?在何种情况下使用呢? □ var关键字用来隐式地声明一个数据类型,变量类型是在编译期确定的,而不是在运行时确 ...
- org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundaryRAYPKeHKTYSNdzc1;charset=UTF-8' not supported
原文:https://www.cnblogs.com/yueli/p/7552888.html 最近同事在做一个图片上传功能.在入参 body 中同时传入文件和其它基本信息结果出现如题异常.在此记录下 ...
- mac securecrt无法记住密码的解决方法
打开secureCRT,菜单preferences--general,找到mac options.然后去掉Use KeyChain选项,这样每次连接服务器后就会自动保存密码了.不同的版本可能这个选项的 ...