How to get a property of type "record" using the TypInfo module

I have this type of record

TDoublePoint = record
               X : Double;
               Y : Double;
               end;

then I have an object with this property

uses ..TypInfo;

TCell = class(TPersistent)
  private
    FZoom : TDoublePoint 
  published
    property Zoom : TDoublePoint read FZoom write FZoom;
end;

But when I want to get the PropInfo of this property using this function:

function GetKind(AObject:TObject; Propertyname :shortstring):TTypeKind;
var p :ppropinfo;
begin
  p:=GetPropInfo(AObject, Propertyname);  // <p = nil
  Result:= p^.proptype^.Kind;
end;

.. ..

c := TCell.Create;
GetKind(c, 'Zoom');  //   <- error
c.Free;

I get an error because the variable p is nil in the function.

But why? There is TTypeKind in it tkRecord, so I did not expect any problems with reading / writing properties of the write type, but it seems to be impossible (?) The Google search did not say much.

+6
source share
1 answer

Delphi 7 RTTI , published, , RTTI ( TypInfo.GetPropList() ).

- :

. , , , , .

. , ( , , ..), RTTI, published, , , , GetPropInfo() ( , Delphi 7).

TDoublePoint , , GetPropInfo() nil TCell.Zoom.

RTTI ​​ ( , . , Delphi 2010, RTTI). , , , XE. GetPropInfo() Zoom, , , , TDoublePoint.

+10

All Articles