unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,typinfo, Vcl.StdCtrls;
type
TmyType = (my1, my2, my3);
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TTest = class(TObject)
public
FName,FSex,FScholl:string;
Fmyfloat:double;
Fmyboolean:boolean;
Fmymy:TmyType;
published
property Name :string read FName write FName;
property Sex :string read FSex write FSex;
property Scholl :string read FScholl write FScholl;
property myfloat:double read Fmyfloat write Fmyfloat;
property myboolean:boolean read Fmyboolean write Fmyboolean;
property mymy:TmyType read Fmymy write Fmymy;
end;
type
TDot = class
private // 专用
public // 共享
Fx: double;
Fy: double;
published // 发布
property x: double read Fx write Fx;
property y: double read Fy write Fy;
end;
type
TEntity = class
private // 专用
public // 共享
FID: LongWord; // 实体编号 4
fEType: byte; // 实体类型 1
fLaye: byte; // 实体图层 1
fLineType: byte; // 实体线型 1
fLineWidth: byte; // 实体线宽 1
fPenColor: byte; // 实体画笔颜色 1
fbrushColor: byte; // 实体填充颜色 1
fbrushstyle: byte; // 实体填充样式 1
fSelected: boolean; // 是否选定 1
Fselectno: integer; // 选定控制点编号 1
protected // 保护
public // 共享
published // 发布
property ID: LongWord read FID write FID;
property laye: byte read fLaye write fLaye;
property Etype: byte read fEType write fEType;
property linewidth: byte read fLineWidth write fLineWidth;
property pencolor: byte read fPenColor write fPenColor;
property linetype: byte read fLineType write fLineType;
property brushColor: byte read fbrushColor write fbrushColor;
property brushStyle: byte read fbrushstyle write fbrushstyle;
property Selected: boolean read fSelected write fSelected;
property Selectno: integer read Fselectno write Fselectno;
end;
type
TCADLine = class(TEntity)
private // 专用
public // 共享
fdot0: TDot;
fdot1: TDot;
protected // 保护
public // 共享
constructor Create();
destructor Destroy;
published // 发布
property dot0: TDot read fdot0 write fdot0;
property dot1: TDot read fdot1 write fdot1;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TCADLine.Create();
begin
inherited Create();
;
fdot0 := TDot.Create;
fdot1 := TDot.Create;
fdot0.x := 21;
fdot0.y := 22;
fdot1.x := 34;
fdot1.y := 35;
end;
destructor TCADLine.Destroy;
begin
fdot0.Free;
fdot1.Free;
inherited Destroy;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
PropCount, I: SmallInt;
PropList: PPropList;
PropStr,sValues: string;
PropCount1, j: SmallInt;
PropList1: PPropList;
PropStr1,sValues1: string;
Tmytmp : TObject;
AClass:TTest;
myLine:TCADLine;
begin
AClass:=TTest.Create;
AClass.Name:='MyTest';
AClass.Sex:='Male';
AClass.Scholl:='Scholl';
AClass.myfloat:=0.99;
AClass.myboolean:=false;
AClass.mymy:=my2;
myLine:=TCADLine.Create;
myLine.id:=6;
myLine.LineWidth:=23;
myLine.dot0.x:=23.5;
myLine.dot0.y:=33.5;
PropCount := GetTypeData(AClass.ClassInfo).PropCount;
GetPropList(AClass.ClassInfo, PropList);
for I := 0 to PropCount - 1 do
begin
case PropList[I]^.PropType^.Kind of
tkClass : PropStr := '[Class] ';
tkMethod : PropStr := '[Method]';
tkSet : PropStr := '[Set] ';
tkEnumeration: PropStr := '[Enum] ';
else
PropStr := '[Field] ';
end;
PropStr := PropStr + PropList[I]^.Name;
PropStr := PropStr + ' : ' + PropList[I]^.PropType^.Name;
sValues:=GetPropValue(AClass,PropList[I].Name,True);
ShowMessage(PropStr+' : '+sValues);
end;
PropCount := GetTypeData(myline.ClassInfo).PropCount;
GetPropList(myline.ClassInfo, PropList);
for I := 0 to PropCount - 1 do
begin
case PropList[I]^.PropType^.Kind of
tkClass : PropStr := '[Class] '; //对象
tkMethod : PropStr := '[Method]'; //方法
tkSet : PropStr := '[Set] '; //集合
tkEnumeration: PropStr := '[Enum] '; //枚举
else
PropStr := '[Field] ';
end;
PropStr := PropStr + PropList[I]^.Name;
PropStr := PropStr + ' : ' + PropList[I]^.PropType^.Name;
if PropList[I]^.PropType^.Kind=tkClass then
begin
Tmytmp:=getobjectprop(myline,PropList[I],tdot);
PropCount1 := GetTypeData(Tmytmp.ClassInfo).PropCount;
GetPropList(Tmytmp.ClassInfo, PropList1);
for j := 0 to PropCount1 - 1 do
begin
case PropList[j]^.PropType^.Kind of
tkClass : PropStr := '[Class] ';
tkMethod : PropStr := '[Method]';
tkSet : PropStr := '[Set] ';
tkEnumeration: PropStr := '[Enum] ';
else
PropStr1 := '[Field] ';
end;
PropStr1 := PropStr1 + PropList[j]^.Name;
PropStr1 := PropStr1 + ' : ' + PropList[j]^.PropType^.Name;
sValues:=GetPropValue(Tmytmp,PropList1[j].Name,True);
ShowMessage(PropStr+' : '+sValues);
end;
end
else
begin
sValues:=GetPropValue(myLine,PropList[I].Name,True);
ShowMessage(PropStr+' : '+sValues);
end;
end;
FreeMem(PropList);
end;
end.