GDI+计算文本矩形区域
2017-07-05 15:04
381 查看
功能:限定宽度的情况下,测试文本所占区域
附录:
The Graphics::MeasureString method measures the extent of the string in the specified font and layout rectangle.
Syntax
Parameters
Return value
CPaintDC dc(this); Graphics g(dc.GetSafeHdc()); Gdiplus::Font font(L"华文新魏", 30); Gdiplus::StringFormat sf; Gdiplus::RectF rectLayer; rectLayer.X = 0; rectLayer.Y = 0; rectLayer.Width = 1000; rectLayer.Height = -1; Gdiplus::RectF boundingBox; g.MeasureString(m_text, -1, &font, rectLayer, &boundingBox ); g.DrawString(m_text, -1, &font, boundingBox, &sf, &Gdiplus::SolidBrush(Gdiplus::Color(255, 0, 0)) );
附录:
The Graphics::MeasureString method measures the extent of the string in the specified font and layout rectangle.
Syntax
Status MeasureString( [in] const WCHAR *string, [in] INT length, [in] const Font *font, [in, ref] const RectF &layoutRect, [out] RectF *boundingBox ) const;
Parameters
string [in] Type: const WCHAR* Pointer to a wide-character string to be measured. Important For bidirectional languages, such as Arabic, the string length must not exceed 2046 characters. length [in] Type: INT Integer that specifies the number of characters in the string array. The length parameter can be set to –1 if the string is null terminated. font [in] Type: const Font* Pointer to a Font object that specifies the family name, size, and style of the font that is applied to the string. layoutRect [in, ref] Type: const RectF Reference to a rectangle that bounds the string. boundingBox [out] Type: RectF* Pointer to a RectF object that receives the rectangle that bounds the string.
Return value
Type: Type: Status If the method succeeds, it returns OK, which is an element of the Status enumeration. If the method fails, it returns one of the other elements of the Status enumeration.
相关文章推荐
- 矩形相交区域的计算
- C#利用GDI+绘制旋转文字,矩形内可以根据布局方式排列文本
- 【教程】PDF开发工具Spire.PDF 教程:使用C#从PDF中的特定矩形区域中提取文本
- j2me中计算两矩形的相交区域算法
- 矩形相交区域的计算
- PDF开发工具Spire.PDF 教程:使用C#从PDF中的特定矩形区域中提取文本
- C# 使用 GDI+ 给图片添加文字,并使文字自适应矩形区域 C# 使用 GDI+ 画图
- 用DT_CALCRECT来计算文本串的区域
- 再学 GDI+[77]: 区域(6) - GetRegionScans - 获取区域中的所有矩形
- 矩形相交 判断 - 相交区域坐标计算
- [iOS]CTFramesetterSuggestFrameSizeWithConstraints计算文本显示所占区域修正方法
- 己知矩形两对角点坐标,计算矩形区域内所有坐标
- 计算矩形相交区域
- C#利用GDI+给图片添加文字(文字自适应矩形区域)
- 蓝桥杯 矩形区域的交和并 计算几何
- 再学 GDI+[45]: 文本输出 - 在矩形中格式化输出
- C# 使用 GDI+ 给图片添加文字,并使文字自适应矩形区域
- 关于ZBar扫描区域的计算
- Qt: 在Qt中计算文本的宽度与高度
- Python 网页爬虫 & 文本处理 & 科学计算 & 机器学习 & 数据挖掘兵器谱