//第二種重載的聲明:
TextRect(
var Rect: TRect; {矩形范圍}
var Text: string; {文本}
TextFormat: TTextFormat = [] {選項; 集合類型, 默認
值是個空的集合}
);
{參數三是 TTextFormat 類型的集合, 它定義如下:}
TTextFormat = set
of TTextFormats;
{TTextFormats 是個枚舉, 定義如下}
TTextFormats = (tfBottom,
tfCalcRect, tfCenter, tfEditControl, tfEndEllipsis,
tfPathEllipsis, tfExpandTabs,
tfExternalLeading, tfLeft, tfModifyString,
tfNoClip, tfNoPrefix, tfRight, tfRtlReading,
tfSingleLine, tfTop,
tfVerticalCenter, tfWordBreak);
{所以參數三可以是下列值之一或它
們的組合}
tfBottom
tfCalcRect
tfCenter
tfEditControl
tfEndEllipsis
tfPathEllipsis
tfExpandTa
bs
tfExternalLeading
tfLeft
tfModifyString
tfNoClip
tfNoPrefix
tfRight
tfRtlReading
tfSingleLine
tfTop
tfVerticalCenter
tfWordBreak
//這個函數是 API
函數 DrawTextEx 的簡化, 可以參見: DrawTextEx
-------------------------------------------
-------------------------------------
//第二種重載的舉例1:
{默認是頂對齊、左對齊; 前兩
個參數都是傳址的, 不能用常量}
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);
end;