[fpc-pascal] GetPropValue and Unknown property
Mattias Gärtner
nc-gaertnma at netcologne.de
Tue Jun 23 15:20:10 CEST 2009
Zitat von "Leonardo M. Ramé" <martinrame at yahoo.com>:
>
>
>
> How are you filling the ASortProps array? if it is by hand, you have
> to take care of Case Sensitivity of property names.
>
> You can use this function to know the published properties of any
> class. Try it inside your DoCompareProps, passing
> TFTPListRec(AItem1).ClassType as param, if AItem1 is an instance it
> should list all its properties:
>
> procedure GetClassProperties(AClass: TClass);
> (* get published properties into a list *)
> var
> PropList: ppropList;
> ClassTypeInfo: PTypeInfo;
> I: Integer;
> lProps: Integer;
> begin
> (* Get properties and a pointer to class *)
> lProps := GetTypeData(AClass.ClassInfo)^.PropCount;
> if lProps <> 0 then
> begin
> (* Properties list to be analyzed *)
> for I := 0 to GetPropList(AClass.ClassInfo, PropList) -1 do
> writeln(PropList[I]^.name);
> end;
> end;
This will create a mem leak. Call GetPropList only once and FreeMem
the PropList at the end.
Mattias
--
Powered by NetMail
More information about the fpc-pascal
mailing list