• 画图学习 [5] TextRect


    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;

    type
    TForm1
    = class(TForm)
    btn1: TButton;
    btn2: TButton;
    btn3: TButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.btn1Click(Sender: TObject);
    const
    s:
    string = 'LJj的Delphi博客';
    r: TRect
    = (Left:0; Top:0; Right:60; Bottom:60);
    begin
    Canvas.Brush.Color :
    = clWhite;
    Canvas.FillRect(r);
    Canvas.TextRect(r,
    10, 10, s);
    end;

    procedure TForm1.btn2Click(Sender: TObject);
    var
    r: TRect;
    s:
    string;
    begin
    r :
    = ClientRect;
    InflateRect(r,
    -100, -10);

    s :
    = 'LJj的Delphi博客';
    Canvas.Brush.Color :
    = clYellow;
    Canvas.FillRect(r);
    Canvas.TextRect(r,s);

    end;

    procedure TForm1.btn3Click(Sender: TObject);
    var
    r: TRect;
    s:
    string;
    begin
    r.Left :
    = 350;
    r.Top :
    = 10;
    r.Right :
    = 720;
    r.Bottom :
    = 100;

    s :
    = 'LJj的Delphi博客';
    Canvas.Brush.Color :
    = clGreen;
    Canvas.FillRect(r);
    Canvas.TextRect(r, s, [tfCenter, tfVerticalCenter, tfSingleLine]);
    end;

    end.

    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
    tfExpandTabs
    tfExternalLeading
    tfLeft
    tfModifyString
    tfNoClip
    tfNoPrefix
    tfRight
    tfRtlReading
    tfSingleLine
    tfTop
    tfVerticalCenter
    tfWordBreak

  • 相关阅读:
    servlet简介
    synchronized锁的升级过程
    volatile的作用及原理
    redis数据类型
    mysql的主从复制
    redis的缓存穿透,缓存击穿,缓存雪崩
    网络从io到多路复用
    mysql索引
    mysql的执行计划
    mysql 常用函数
  • 原文地址:https://www.cnblogs.com/ljjphysics/p/2059998.html
Copyright © 2020-2023  润新知