{
 
在网上看到个这个例子感觉还不错,将它移到自己的博客里没事的时候看看;
 
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. Brain Network (medium)

    Brain Network (medium) Further research on zombie thought processes yielded interesting results. As ...

  2. android脚步---APP引导页添加

    package com.leadcore.uudatoutie; import java.util.ArrayList; import com.leadcore.uudatoutie.R; impor ...

  3. Matplotlib中文显示的问题

    原文地址:http://blog.csdn.net/rumswell/article/details/6544377 #Matplotlib中文显示有问题,当然可以修改配置文件matplotlibrc ...

  4. 扩展方法实现DevExpress控件校验

    DevExpress控件中,如果要控件的值进行校验,需要用到DXValidationProvider控件和DXErrorProvider控件,按照正常思路,无论使用哪个控件要实现校验效果时都需要对每个 ...

  5. Combox下拉绑定DataGridView

    这个Combox下拉很多人都在用  但其中绘制的语句如下: #endregion #region 方法 #region 绘制DataGridView以及下拉DataGridView private v ...

  6. android usb挂载分析

    http://blog.csdn.net/new_abc/article/details/7409018

  7. 针对iOS10的各种问题的解决方法

    1.iOS10相册相机闪退bug: iOS10系统下调用系统相册,相机功能,遇到闪退的情况,描述如下: This app has crashed because it attempted to acc ...

  8. HDU 4408 Minimum Spanning Tree 最小生成树计数

    Minimum Spanning Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  9. log4cxx入门第一篇--一个小例子

    先看官网:http://logging.apache.org/log4cxx/index.html 转载自:http://wenku.baidu.com/view/d88ab5a9d1f34693da ...

  10. postgresql 数据库的备份和恢复 (pg_dump 和 pg_restore)

    pg_dump 用来备份数据库: pg_restore 用来恢复数据库: 备份出来的文件可以用 XZ (linux 自带的压缩工具压缩). XZ压缩最新压缩率之王 xz这个压缩可能很多都很陌生,不过您 ...