UINT CSkin::ComputeStringSize(Graphics &graph,const CString& strObject)
{
Color cr = Color(255,0xff,0xff,0xff);
Pen pen(cr,5.0f);
SolidBrush brush(cr);
FontFamily fontFamily(L"Times New Roman");
Font font(&fontFamily, 11.0f, FontStyleRegular, UnitPixel);
PointF pointF;
pointF.X = 10;
pointF.Y = 10;
RectF stringSize;
CComBSTR bstr = strObject.AllocSysString();
graph.MeasureString(bstr,bstr.Length(),&font,pointF,&stringSize);
return (UINT)stringSize.Width;
}
计算字符串的空间长度(像素)
最新推荐文章于 2024-07-31 14:56:26 发布