procedure TForm1.FormPaint(Sender: TObject);
procedure DrawAll(ACanvas: TCanvas; R: TRect; dx, dy: Integer; C: TColor);
var
ts: TTextStyle;
begin
with Canvas do begin
Font.Color := C;
ts := TextStyle;
ts.Alignment := taLeftJustify;
ts.Layout := tlTop;
TextRect(R, R.Left+dx, R.Top+dy, 'Left/Top', ts);
ts.Layout := tlCenter;
TextRect(R, R.Left+dx, R.Top+dy, 'Left/Center', ts);
ts.Layout := tlBottom;
TextRect(R, R.Left+dx, R.Top+dy, 'Left/Bottom', ts);
ts.Alignment := taCenter;
ts.Layout := tlTop;
TextRect(R, R.Left+dx, R.Top+dy, 'Center/Top', ts);
ts.Layout := tlCenter;
TextRect(R, R.Left+dx, R.Top+dy, 'Center/Center', ts);
ts.Layout := tlBottom;
TextRect(R, R.Left+dx, R.Top+dy, 'Center/Bottom', ts);
ts.Alignment := taRightJustify;
ts.Layout := tlTop;
TextRect(R, R.Left+dx, R.Top+dy, 'Right/Top', ts);
ts.Layout := tlCenter;
TextRect(R, R.Left+dx, R.Top+dy, 'Right/Center', ts);
ts.Layout := tlBottom;
TextRect(R, R.Left+dx, R.Top+dy, 'Right/Bottom', ts);
end;
end;
var
R: TRect;
begin
R := Rect(0, 0, Width, Height);
InflateRect(R, -Width div 8, -Height div 8);
with Canvas do begin
Brush.Color := clWhite;
FillRect(R);
DrawAll(Canvas, R, 0, 0, clBlack);
//DrawAll(Canvas, R, 16, 16, clRed);
end;
end;