GDI+获取字符串输出宽度像素及设置插入符位置精确问题
先贴代码
Graphics gph(hdc);
Pen pen(Color::Green);
SolidBrush br(Color::DarkCyan);
gph.FillRectangle(&br,50,50,250,25);
TCHAR str[] = L"fghrt";
Gdiplus::Font font(L"Arial",12);
StringFormat stringFormat1;
SolidBrush textBrush(Color::Black);
RectF rtf;
gph.DrawString(str,-1,&font,PointF(50.0,50.0),&stringFormat1,&textBrush);
gph.MeasureString(str,wcslen(str)-1,&font,PointF(50.0,50.0),&rtf);
ShowCaret(hWnd);
SetCaretPos((int)(rtf.X+rtf.Width),52);
但插入符的位置偏差很大,有办法解决么 GDI+?
[解决办法]
你的意思是rtf的值不准?