//效果圖:
//第二種重載的舉例2:
{單行文本、水平居中、垂直居中}
procedure TForm1.FormPaint(Sender: TObject);
var
R: TRect;
S: string;
begin
R := ClIEntRect;
InflateRect(R,-10,-10); {把矩形縮小一圈}
S := 'Delphi';
Canvas.Brush.Color := clWhite;
Canvas.FillRect(R);
Canvas.TextRect(R, S , [tfSingleLine, tfCenter, tfVerticalCenter]);
end;
//效果圖: