GDI+ 学习记录(23): 输出文本
//在矩形范围中显示文本 var g: TGPGraphics; fontFamily: TGPFontFamily; font: TGPFont; rectF: TGPRectF; p: TGPPen; sb: TGPSolidBrush; str: WideString; begin g := TGPGraphics.Create(Canvas.Handle); fontFamily:= TGPFontFamily.Create('宋体'); font:= TGPFont.Create(fontFamily, 9, FontStyleRegular, UnitPoint); p := TGPPen.Create(aclRed); sb:= TGPSolidBrush.Create(MakeColor(255, 0, 0, 0)); rectF:= MakeRect(10.0, 10.0, 116.0, 100.0); {包含文本的矩形范围} str := '万一万一万一万一万一万一万一万一万一万一万一万一万一万一万一'; g.DrawRectangle(p, rectF); g.DrawString(str, -1, font, rectF, nil, sb); {参数4不能用TGPRect,只能是TGPRectF; 参数5是文字格式对象,后面举例} fontFamily