Examples Delphi

OBJECT PROPERTIES
Hi!
I've been subsribing to this list for some time now, without ever
answering. Here's my first go...
I'm using a property iterator as an utility I use with my classes.
Here it is:
-----------------------------------------------------------------------------------
USES
{!Delphi5!}
Classes, TypInfo
;
procedure GetPropertyNames
(
p_Persistent : TObject; //object to "read"
p_List : TStringList; //list of properties
p_Filter : TTypeKinds //restrict search to some set of properties
);
{returns property names list for the object}
var
l_Count : integer;
l_Size : integer;
l_List : PPropList;
l_Ix : integer;
l_Filter : TTypeKinds;
begin
l_Filter := p_Filter;
p_List.Clear;
l_Count := GetPropList(p_Persistent.ClassInfo, l_Filter, nil);
l_Size := l_Count * SizeOf(Pointer);
GetMem(l_List, l_Size);
try
GetPropList(p_Persistent.ClassInfo, l_Filter, l_List);
for l_Ix := 0 to l_Count - 1 do
p_List.Add(l_List[l_Ix].Name);
finally
FreeMem(l_List, l_Size);
end;
end;{GetPropertyNames}
-------------------------------------------------------------------------------------
I think this is quite self-explanatory.
Note:
This code is from an article by Peter Hinrichsen in
The Delphi Magazine - issue 54 (Feb 2000)
HTH,
Cheers from Bordeaux,
--
Jean-Francois Nifenecker, Bordeaux (Europe)
jfnif@compuserve.com