在Delphi的属性 property中使用数组
来源:互联网 发布:xbox360手柄连接mac 编辑:程序博客网 时间:2024/06/01 09:32
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TGCNodeRec = record QVehicleArrayID:Integer; GCCount:Integer; GCDirection:string; QCDirection:string;end;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; type Ts = array[0..19] of TGCNodeRec; type TCompass = class private FHeading: Ts; function GetHeading(index:Integer): TGCNodeRec; procedure SetHeading(index:Integer;Value: TGCNodeRec); public //注以下定义属性,Published中不允许使用,在Public中运行正常 ; Published中不允许使用数组 property PHeading[index:Integer]: TGCNodeRec read GetHeading write SetHeading; default; end;var Form1: TForm1;implementation{$R *.dfm}function TCompass.GetHeading(index:Integer): TGCNodeRec;begin Result := fheading[index];end;procedure TCompass.SetHeading(index:Integer;Value: TGCNodeRec);begin FHeading[index] := Value;end;procedure TForm1.Button1Click(Sender: TObject);var MyClass:TCompass; GcNode : TGCNodeRec;begin GcNode.GCDirection := '测试'; MyClass := TCompass.create; MyClass.PHeading[0] := GcNode; //给属性赋值, 自动调用 SetHeading函数为数组0号元素赋值 //以下2种方式调用都可以 返回的结果是一样的 ShowMessage(MyClass.FHeading[0].GCDirection); ShowMessage(MyClass.PHeading[0].GCDirection );end;end.
公布成员(published)和公共成员(public)具有相同的可见度,但published中声明的会显示在属性栏,public 不会!
published和public的限制访问属性是一样的 ;不过,published一般用于组件编程中,而不常用于应用程序中。
转自OBJECT PASCAL
"公布成员(published)和公共成员(public)具有相同的可见度。不同的是,运行时信息RTTI(runtime type information)为公布成员产生。RTTI允许应用程序动态地查询对象的域和属性、定位对象的方法。RTTI用于在下列情形下访问属性的值:保存和加载文件时,在对象检查器(Object Inspector)中显示属性时,将指定的方法(即事件处理程序)与指定的属性(即事件)关联时。
公布属性只限于某些数据类型。序数、串、类、接口和方法指针等类型可以被公布;由此可见,提供的基类型其上下界范围的序数值在0到31之间的集合类型也可以被公布,即集合必需适合于字节、字或双字(Byte,Word或Double Word);除Real48之外,任何实数类型都可以被公布。数组类型的属性(不同于下面述及的数组属性array properties)不能被公布。"
- 在Delphi的属性 property中使用数组
- 在Delphi的属性 property中使用数组-第一篇转载
- 在Python中使用属性Property
- delphi property 实例(包含数组属性)
- property的使用【Delphi版】
- 在ibatis中使用Dynamic SQL时property属性的用法
- Attached Property在Xaml中,使用Property Element的写法
- C++中使用属性(property)
- Delphi 中的属性property
- OC中@property的各种属性的使用详解
- delphi中记录数组的使用练习
- delphi的属性property和消息处理特点事件属性。
- Spring 配置文件中 Bean 的 property 属性使用示例
- Android Property属性的使用
- 在C++中实现“属性 (Property)”
- delphi property中default的含义
- 在Delphi中使用复杂的SQL
- 在Delphi中WaitForMultipleObjects的使用
- Ubuntu 12.04 常用的快捷键
- 商务通话容易忽视的细节
- 自由的追求—写给新农网和他的创业者们
- HDU1005矩阵相乘二分法
- VC++实现获取所有的TCP与UDP链接
- 在Delphi的属性 property中使用数组
- EXT 双击事件
- 最大流算法
- .月薪一万的乞丐给我上了震撼一课
- mac os 安装mysql
- USB学习小记-HID类学习流程
- 人在旅途(曹门知青郑立光先生旧文)
- 杭电OJ——1283 最简单的计算机
- 献血--爱心与责任