m_pSonicString[1]->Format(_T("/c=%x, a='http://hi.csdn.net/', linkh=0xFF00F0, font, font_height=25, font_bold=1, font_italic=1/点我打开链接uM"),RGB(128,0,32));
m_pSonicString[2]->Format(_T("/c=%x, a='http://hi.csdn.net/', linkh=0xFF00F0, font, font_height=25, font_bold=1, font_italic=0/点我打开链接uM"),RGB(128,0,32));

測试代码如上:

通过代码分析,发现了作者使用的是 API GetTextExtentPoint32

BOOL GetTextExtentPoint32(  HDC hdc,           // handle to DC
LPCTSTR lpString, // text string int c, // characters in string
LPSIZE lpSize // string size);

这个是函数是能够获取到字符串的宽度。。可是没有区分Italic类型,所以才会出现以上高亮后的问题。

if (block.Font.bItalic)
{
UINT nChar = (UINT)block.strText.GetAt(strlen(block.strText) + -1);
if (nChar >= 0xA0)
{
nChar = ((UINT)block.strText.GetAt(strlen(block.strText) + -2) >> 8) + nChar;
nChar = nChar & 0xFFFF;
int nWidth;
GetCharWidth32(hdc,nChar ,nChar ,&nWidth);
nBlockWidth = sz.cx + nWidth;
}
else
{
ABC czAbc = {0};
GetCharABCWidths(hdc,nChar,nChar,&czAbc);
nBlockWidth = sz.cx - czAbc.abcC;
}
}
else
{
nBlockWidth = sz.cx;
}

\SonicUI_src\SonicUI\SonicString.cpp  477line     更改支持中英文。

</pre><pre class="cpp" name="code">BOOL GetCharABCWidths(  HDC hdc,         // handle to DC
UINT uFirstChar, // first character in range
UINT uLastChar, // last character in range
LPABC lpabc // array of character widths);

通过这个函数获取当前字体下,最后一个字符的宽度。

。能够非常好的全然显示出来!



最新文章

  1. Net设计模式实例之单例模式( Singleton Pattern)
  2. 让ie6对png透明图片支持起来
  3. WinCE\Window Mobile程序桌面化总结
  4. JS性能消耗在哪里?
  5. Java 实现学生信息管理系统
  6. 万网免费主机wordpress快速建站教程-wordpress下载及安装
  7. git入门超详细(转载)
  8. Altium Designer打印设置
  9. CSS中的尺寸单位
  10. 【BZOJ2337】Xor和路径(高斯消元)
  11. windows下用cmd命令netstat查看系统端口使用情况
  12. 【转载】 C#检测输入的内容中是否含有中文
  13. shell脚本简介
  14. Spark MLlib 机器学习
  15. SpringBoot整合dubbo
  16. String.format(String format, Object... args)方法详解
  17. 【下一代核心技术DevOps】:(三)私有代码库阿里云Git使用
  18. SoapUI Pro Project Solution Collection-access the soapui object
  19. Win32汇编学习(4):绘制文本
  20. 【TP3.2+onethink1.0】2个Ueditor 回显数据,第2个会把第1个覆盖

热门文章

  1. Controller接口控制器
  2. asp.net MVC4.0中几种控制器的区别
  3. BZOJ 4430 Guessing Camels
  4. 【Uva 1629】 Cake slicing
  5. MySQL改变表的存储引擎
  6. 深入理解javascript之高级定时器
  7. js---03属性操作
  8. js实现动态添加事件
  9. single-page关于vue-router
  10. 41.内存函数实现(memcpy,memset,memmove,memicmp,memchr.memccpy)