{
 
在网上看到个这个例子感觉还不错,将它移到自己的博客里没事的时候看看;
 
TRect
   作用:保存一个矩形的左上角和右下角的坐标值;
 
   声明:
 
    type TRect = packed record
    case integer of
 
      0:(Left, Top, Right, Botton:Integer);
      1:(TopLeft, BottonRight:TPoint);
    end;
 
    由上面的TRect可知,TRect是一个记录类型(TRect),保存了矩形的左上角右下角两个点,4个坐标
    或2个点的值。
    这个声明是Record类型使用Case子句的典型的例子。
    当我们通TopLeft和BottonRight两个点创建矩形时,可以传递两个TPoint值或用Point函数产生他们;
 
}
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
  rectangle1, rectangle2:TRect;
begin
  //用Rectangle来手工设置一个矩形;
  Rectangle1.Left := 0;
  rectangle1.Top := 0;
  rectangle1.Right := 40;
  rectangle1.Bottom := 60;
 
  //再用Rect函数设置第二个矩形;
  Rectangle2 := Rect(Point(20, 40), Point(60, 80));
 
  //显示每个矩形的左上角和左下角的坐标
 
  ShowMessageFmt('Rectangle 1 coords = %d, %d, %d, %d',
                 [rectangle1.left,
                  rectangle1.top,
                  rectangle1.Right,
                  rectangle1.Bottom]);
 
  ShowMessageFmt('Rectangle 2 coords = %d, %d, %d, %d',
                 [rectangle2.Left,
                  rectangle2.Top,
                  rectangle2.Right,
                  rectangle2.Bottom]);
 
end;
 
 
end.

Delphi TRect函数例子的更多相关文章

  1. Delphi回调函数的使用-例子

    Delphi回调函数的使用-例子 功能大体描述:Form1中有一个Edit和一个Button,当点击BUTTON时弹出FORM2,FORM2中也有一个EDIT和一个BUTTON,当点击FORM2中的B ...

  2. Delphi Canvas的FillRect(const Rect: TRect) 函数的作用

    http://blog.163.com/zhangzhifeng688@126/blog/static/165262758201131211341460/ Delphi Canvas的FillRect ...

  3. delphi公共函数 UMyPubFuncFroc--版权所有 (C) 2008 勇者工作室

    {*******************************************************} { } { Delphi公用函数单元 } { } { 版权所有 (C) 2008 勇 ...

  4. delphi字符串函数大全

    转帖:delphi字符串函数大全 2009-11-17 16:43:55 分类: delphi字符串函数大全 ━━━━━━━━━━━━━━━━━━━━━首部 function StringToGUID ...

  5. delphi公用函数

    {*******************************************************} { } { Delphi公用函数单元 } { } { 版权所有 (C) 2008 } ...

  6. (转载)delphi 常用函数(数学)

    delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里的函数,使用前要先 Uses Math.trunc 和 round 是 system ...

  7. Delphi回调函数及其使用

    Delphi回调函数及其使用 1 回调函数的概述 回调函数是这样一种机制:调用者在初始化一个对象(这里的对象是泛指,包括OOP中的对象.全局函数等)时,将一些参数传递给对象,同时将一个调用者可以访问的 ...

  8. Delphi过程函数传递参数的八种方式

    今天一同事问我为什么有些过程函数里面有Var而有些没有,不解,遂到网上百度,得解.快哉,快哉. 在Delphi过程.函数中传递参数几个修饰符为Const.Var.Out.另一种不加修饰符的为默认按值传 ...

  9. Delphi 常用函数(数学函数)round、trunc、ceil和floor

    源:Delphi 常用函数(数学函数)round.trunc.ceil和floor Delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里 ...

随机推荐

  1. DIV撑开

    引用自:http://radzhang.iteye.com/blog/1678734 在CSS排版中,如果一个层中的层使用了float浮动的话,那么就有可能会出现外层没有被内层撑开的情况,如以下代码所 ...

  2. apk反汇编之smali语法

    类型 Dalvik的字节码中拥有两个主要的类型:基类和引用类型.引用类型 引用类型是对象和数组,其他的一切都是基类   基类被一个简单的字符描述.我没有提出这些缩写词———他们实际以字符串的形式存储于 ...

  3. openwrt系统之字符设备驱动软件包加载、测试程序加载

    .首先将软件包(如mydrv)放到ubuntu虚拟机openwrt/trunk/package/kernel/目录下 .回到openwrt/trunk/目录下,make menuconfig进行配置, ...

  4. PAT (Advanced Level) 1056. Mice and Rice (25)

    简单模拟. #include<iostream> #include<cstring> #include<cmath> #include<algorithm&g ...

  5. springMVC和spring上下文的关系

    springMVC继承了spring的servletcontext上下文, 所以, controller里的@Resource注入可以用以下替代 @Resource private IUserServ ...

  6. pe and elf

    http://staff.ustc.edu.cn/~sycheng/sst/exp_crack/ELF.pdf https://refspecs.linuxbase.org/elf/TIS1.1.pd ...

  7. flex中form表单中子元素之间的距离控制

    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.ado ...

  8. [转] spring事务管理几种方式

    前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识.通过这次的学习发觉Spring的事务配置只要把思路理清,还是比较好掌握的. ...

  9. iOS学习基本常识

    转发至:http://blog.sina.com.cn/s/blog_9266da3d010184i0.html 1. 了解main函数,  UIApplication是初始化程序的核心,它接受4个参 ...

  10. Nginx Image Module图片缩略图 水印处理模块

    Nginx Image Module图片缩略图 水印处理模块 下载Tengine tar -zxvf tengine-1.4.5.tar.gz cd tengine-1.4.5 下载Nginx tar ...