• 画图学习 [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

  • 相关阅读:
    quartz CronExpression表达式
    nginx配置文件说明
    mysql的日期输出格式列出来
    linux配置定时备份mysql数据库
    Nginx 配置
    查看mysql 服务有哪些ip地址在连接。
    对HelloWorld进行探究
    SpringBoot热部署与启动速度优化
    SpringBoot 快速入门
    初始SpringBoot
  • 原文地址:https://www.cnblogs.com/ljjphysics/p/2059998.html
Copyright © 2020-2023  润新知