DrawText显示多行文本并能控制行距
来源:互联网 发布:linux 免驱动无线网卡 编辑:程序博客网 时间:2024/04/30 00:37
void CVFLDlg::DrawMultLineText(CDC *pDC, CRect rect, int nRowDis, UINT nFromat, CString strText)
{
if( strText.GetLength() <= 0 )
return;
WCHAR* pText = strText.GetBuffer(strText.GetLength());
int nCount = strText.GetLength();
CRect rtChar;
CSize size = pDC->GetTextExtent(pText + 0, 1);
int nRowHeight = size.cy + nRowDis;
rtChar.top = rect.top;
rtChar.left = rect.left;
rtChar.bottom = rtChar.top + nRowDis + size.cy;
rtChar.right = rtChar.left + size.cx;
CString strChar;
for (int nCharIndex = 0; nCharIndex < nCount; nCharIndex++)
{
if( rtChar.right > rect.right )
{
rtChar.top = rtChar.bottom;
rtChar.bottom += nRowHeight;
size = pDC->GetTextExtent(pText + nCharIndex, 1);
rtChar.left = rect.left;
rtChar.right = rtChar.left + size.cx;
if( rtChar.bottom > rect.bottom )
break;
}
strChar = pText[nCharIndex];
pDC->DrawText(strChar, rtChar, nFromat);
size = pDC->GetTextExtent(pText + nCharIndex + 1, 1);
rtChar.left = rtChar.right;
rtChar.right += size.cx;
}
}
{
if( strText.GetLength() <= 0 )
return;
WCHAR* pText = strText.GetBuffer(strText.GetLength());
int nCount = strText.GetLength();
CRect rtChar;
CSize size = pDC->GetTextExtent(pText + 0, 1);
int nRowHeight = size.cy + nRowDis;
rtChar.top = rect.top;
rtChar.left = rect.left;
rtChar.bottom = rtChar.top + nRowDis + size.cy;
rtChar.right = rtChar.left + size.cx;
CString strChar;
for (int nCharIndex = 0; nCharIndex < nCount; nCharIndex++)
{
if( rtChar.right > rect.right )
{
rtChar.top = rtChar.bottom;
rtChar.bottom += nRowHeight;
size = pDC->GetTextExtent(pText + nCharIndex, 1);
rtChar.left = rect.left;
rtChar.right = rtChar.left + size.cx;
if( rtChar.bottom > rect.bottom )
break;
}
strChar = pText[nCharIndex];
pDC->DrawText(strChar, rtChar, nFromat);
size = pDC->GetTextExtent(pText + nCharIndex + 1, 1);
rtChar.left = rtChar.right;
rtChar.right += size.cx;
}
}
- DrawText显示多行文本并能控制行距
- css控制多行文本显示省略号
- DrawText多行文本垂直居中
- 控制多行文本
- 怎么能正常显示多行文本呢?
- delphi下DrawText多行文本输出,英文有问题
- SetDlgItemText显示多行文本
- 多行文本显示省略号
- svg中显示多行文本
- TextOut显示多行文本的方法
- TextBox显示多行文本/Environment.NewLine
- svg中显示多行文本
- Iphone UILabel显示多行文本
- 多行文本溢出显示省略号...
- 多行文本溢出显示省略号…
- UILabel显示多行文本,字体设置
- WebKit多行文本溢出显示省略号(...)
- 多行文本溢出显示省略号
- 怎么在JSP里面插入Flash播放器
- How to set an IIS Application or AppPool to use ASP.NET 3.5 rather than 2.0
- JNI + C++ (VS2010) 之 Hello World.
- GridView如何将分页数据全部导出为EXCEL
- eclipse 整合 svn
- DrawText显示多行文本并能控制行距
- java并发编程-Executor框架
- CDN技术
- 用于调试的宏
- loadrunner 负载压力测试 关于错误号26627
- SQL DDL触发器
- 目前常见的加密壳列表
- 依赖倒置原则
- 一道sizeof的问题