下面是Delphi对TRect的定义
type 
TPoint = record
  X: Longint;
  Y: Longint;
end;TRect = record
  case Integer of
    0: (Left, Top, Right, Bottom: Integer);
    1: (TopLeft, BottomRight: TPoint);
end;
我的问题是:
  case Integer of 在上面语句中是什么意思? 使用TRect的时候怎么用?

解决方案 »

  1.   

    相当于C/C++/C#的union。个人以为。
      

  2.   

    union RECT {
    struct {
    int Left,Top,Right,Bottom;
    }Rec1;
    struct {
    POINTAPI TopLeft,BottomRight;
    }Rec2;
    }
      

  3.   

    Left, Top, Right, Bottom: Integer中的Left和TopLeft, BottomRight: TPoint中的TopLeft在内存中的地址是一样的。
      

  4.   

    声明
    TRect = record
      case Integer of
        0: (Left, Top, Right, Bottom: Integer);
        1: (TopLeft, BottomRight: TPoint);
    end;
    中,Integer是数据类型,0和1是它的两个值,这个声明的意思是说内存中有一块区域存放了四个整型值,你可以用TRect.Left,TRect.Top...来访问,也可以用TRect.TopLeft来访问。用不到0和1这两个值的,他们仅仅为可读性而存在。
      

  5.   

    这么说也可以用:
    case Boolean of
    False:(...);
    True:(...);是吗?